akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int X, Y;
	int turu, kame;
	if (scanf("%d%d", &X, &Y) != 2) return 1;
	for (turu = 0; turu <= X; turu++) {
		kame = X - turu;
		if (2 * turu + 4 * kame == Y) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 1660
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>

using namespace std;

string itoa(int a,int n){
  char s[22],f[22];
  sprintf(f,"%%0%dd",n);
  sprintf(s,f,a);
  return string(s);
}

int v[1000000];
int main(void)
{
  int a,l,res;
  for(;;) {
    scanf("%d%d",&a,&l); if(a+l==0)break;
    fill(v,v+1000000,-1);
    res = 0;
    while(v[a] < 0) {
      v[a] = res++;
      string p = itoa(a,l), q = itoa(a,l);
      sort(p.begin(),p.end());
      sort(q.rbegin(),q.rend());
      a = atoi(q.c_str())-atoi(p.c_str());
    }
    printf("%d %d %d\n",v[a],a,res-v[a]);
  }
  return 0;
}

Measured memory_bytes: 5016
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <stdio.h>

using namespace std;

void solve() {
    int a, b; cin >> a >> b;
    cout << a*b -(a+b-1) << endl;
}

int main() {
    solve();
    return 0;
}

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

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> X(N);
    for (int i = 0; i < N; i++)
    {
        cin >> X[i];
    }
    vector<int> Y = X;
    sort(Y.begin(), Y.end());
    int ans_min = Y[Y.size() / 2 - 1];
    int ans_max = Y[Y.size() / 2];

    for (int i = 0; i < X.size(); i++)
    {
        if (X[i] <= ans_min)
        {
            cout << ans_max << endl;
        }
        else
        {
            cout << ans_min << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();

#define MAXX 500005
#define PI 3.14159265358979323846264338327950
#define F first
#define S second
#define ll  long long int
#define mod  1000000007



int main()
{
	FAST;
	ll n;
	ll x = 1000;
	cin >> n;
	ll a[n+4];
	for(ll i = 0; i < n; i ++){
		cin >> a[i];
	}
	vector< pair <int, int> > v;
	ll k = 0;; ll z = 0;
	bool fl = true;
	a[n] = -1;
	for(ll i = 0; i < n; i ++){					
		if(a[i] > a[i+1]){
			fl = false;
			
			v.push_back( {a[z], a[i]} );
			z = i+1;
			
			k ++;
		}
	}
	
	ll y;
	for(ll i = 0; i < k; i ++){
		y = x / v[i].first;
		x -= y* v[i].first;
		x += y* v[i].second;
	}
	cout << x;
}


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

#define ll long long
#define pb push_back

const int MAXN = 1e5+5; 

vector<int>G[MAXN];
ll dp[MAXN];
int in[MAXN], n, m;
queue<int> que;

void read() {
	cin >> n >> m;
	for(int i=0; i<m; i++)	{
		int a, b;	cin >> a >> b;
		G[a].pb(b);
		++in[b];
	}
}

void prepare() {
	fill(dp, dp+MAXN, LLONG_MAX);
	for(int i=1; i<=n; i++) {
		if(in[i]==0)	{
			que.push(i);	dp[i]=0;
		}		
	}
}

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

	read();
	prepare();
	while(!que.empty())	{
		int front = que.front();
		que.pop();
		for(int i : G[front]) {
			if(dp[i] == LLONG_MAX)
				dp[i] = dp[front]+1LL;
			dp[i] = max(dp[i], dp[front]+1LL);
			in[i]--;
			if(in[i] == 0)
				que.push(i);
		}
	}	
	ll res = 0;
	for(int i=1; i<=n; i++)
		res = max(res, dp[i]);
	cout << res;
}	


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define all(x) x.begin(), x.end()
#define watch(x) cout<<#x<<" : "<<x<<endl
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define testCases int tt;cin>>tt; while(tt--)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef vector<string> vs;

int main() {
    fastio;
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    ll answer = 0;
    for (int i = 1; i < n; i++) {
        int temp = 0;
        if (arr[i] < arr[i-1]) {
            temp = arr[i-1]-arr[i];
            answer+=temp;
            arr[i] = arr[i-1];
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 4412
n = int(input())

l = []
for i in range(n):
    s = list(input())
    s.sort()
    s = "".join(s)
    l.append(s)

m = {}
ans = 0

for s in l:
    if s in m:
        m[s] += 1
        ans += m[s]
    else:
        m[s] = 0

print(ans)

Measured memory_bytes: 19500
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b] = input
    .trim()
    .split(" ")
    .map((e) => Number(e));
  const result = Math.ceil((a + b) / 2);

  // console.logは標準出力に1行出力します (自動的に最後に改行が入ります)
  console.log(result);
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29528
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n;
	cin >> n;
	int abc[n][3];
	for (int i = 0; i < n; i++) cin >> abc[i][0] >> abc[i][1] >> abc[i][2];
	
	int dp[n][3];
	for (int i = 0; i < 3; i++) dp[0][i] = abc[0][i];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			dp[i][j] = 0;
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + abc[i][j]);
			}
//			cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}
	int ans{};
	for (int i = 0; i < 3; i++) ans = max(ans, dp[n - 1][i]);
	cout << ans;
}

Measured memory_bytes: 5924
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
const long long MAX_V = 1000 * 110;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, w; cin >> n >> w;
    int val[n + 1], weight[n + 1];
    for(int i = 0; i < n; i++)  cin >> val[i] >> weight[i];
    vector<vector<int>> dp(n + 1, vector<int>(MAX_V + 1, INF));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j <= MAX_V; j++)
        {
            if(j - val[i] < 0)
            {
                dp[i + 1][j] = dp[i][j];
            }
            else 
            {
                dp[i + 1][j] = min(dp[i][j], dp[i][j - val[i]] + weight[i]);
            }
        }
    }
    int ans;
    for(int v = 0; v <= MAX_V; v++)
    {
        if(dp[n][v] <= w) ans = v;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 46948
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second

using namespace std;

const long long MOD = (long long)1e9 + 7;

int gcd(int x, int y)
{
	if (x%y)
		return gcd(y, x%y);
	else
		return y;
}

int n, a[100009];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = a[0];
	for (int i = 1; i < n; i++) ans = gcd(ans, a[i]);
	cout << ans << "\n";
	//system("pause");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
typedef pair<ll,mp> mmp;

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

int main(){
 while(1){
  ll t,n;
  cin>>t>>n;
  set<mp> go,stop;
  if(t==0)break;
  for(ll i=0;i<n;i++){
   mp d;
   cin>>d.first>>d.second;
   stop.insert( d );
  }
  mp s;
  cin>>s.first>>s.second;
  queue<mmp> q;
  q.push( mmp( t , s ) );
  while( !q.empty() ){
   mmp now = q.front();
   q.pop();
   ll cnt = now.first;
   mp z = now.second;
   ll x = z.first;
   ll y = z.second;
   if( go.find(z) != go.end() ) continue;
   go.insert( z );
   if( cnt == 0 ) continue;
   
   for(ll i=0;i<6;i++){
    ll nx = x + dx[i];
    ll ny = y + dy[i];
    mp nz = mp(nx,ny);
    if( go.find( nz ) != go.end() ) continue;
    if( stop.find(nz ) != stop.end() ) continue;
    q.push( mmp(cnt-1,nz) );
   }

  }

  cout<<go.size()<<endl;
 }
    return 0;
}



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

int N,M;
int a,b;
vector <int> H;
vector <int> A;
vector <int> B;

void input(){
  cin >> N >> M ;
  H.resize(N);
  for(int i=0;i<N;i++){
    cin >> H[i] ;
  }
  A.resize(N);
  B.resize(N);
  for(int i=0;i<N;i++){
    A[i]=0;
    B[i]=0;
  }

  for(int i=0;i<M;i++){
    cin >> a >> b ;
    A[a-1]=max(A[a-1],H[b-1]);
    B[b-1]=max(B[b-1],H[a-1]);
  }
}

void solve(){
  int d=0;
  for(int i=0;i<N;i++){
    if((H[i]>A[i])&&H[i]>B[i]){
//    if(H[i]>A[i]){
      d+=1;
    }
  } 
  cout << d << endl;
}

int main(){
  input();
  solve();
  return 0;
}


Measured memory_bytes: 4556
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  i64 N;
  cin >> N;
  vector<i64> X(N);
  rep(i,0,N) {
    cin >> X[i];
  }
  i64 ans = 1e18;
  rep(p,1,101) {
    i64 sum = 0;
    rep(i,0,N) {
      sum += (X[i] - p) * (X[i] - p);
    }
    ans = std::min(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll 		long long
#define pb 		push_back
#define hell	1000000007
#define all(x) 	x.begin(),x.end()

using namespace std;

vector<int> R;
ll int d;
ll int dp[10005][2][105];

ll int solve(ll int len,ll int isequal,ll int make)
{
	if(len==-1)
	{
		return make==0;
	}
	ll int ret=0;
	if(dp[len][isequal][make]!=-1) return dp[len][isequal][make];
	if(isequal==0)
	{
		for(int i=0;i<=9;i++)
		{
			ret=(ret+solve(len-1,0,(make-i+100*d)%d))%hell;
		}
	}
	else
	{
		for(int i=0;i<=R[len];i++)
		{
			if(i<R[len]) ret=(ret+solve(len-1,0,(make-i+100*d)%d))%hell;
			else ret=(ret+solve(len-1,1,(make-i+100*d)%d))%hell;
		}
	}
	return dp[len][isequal][make]=ret%hell;
}

int main()
{
	string s;
	cin>>s;
	reverse(all(s));
	cin>>d;
	for(int i=0;i<s.length();i++) R.pb(s[i]-'0');
	memset(dp,-1,sizeof(dp));
	cout<<(solve(R.size()-1,1,0)+hell-1)%hell;
	return 0;
}

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

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

using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

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

	int a, b; cin >> a >> b;

	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
	}
	else if (a < 0 && b < 0) {
		if (abs(a - b) % 2 == 0)cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
	else if (0 < a && 0 < b) {
		cout << "Positive" << endl;
	}
}	




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

int main(){
    string s;
    cin >> s;
    vector<int> alp(26, 0);
    for(char d : s){
        alp[d - 'a'] = 1;
    }
    bool f = true;
    for(int i = 0; i < 26; i++){
        if(alp[i] == 0){
            f = false;
            cout << char(i + 'a') << endl;
            break;
        }
    }
    if(f) puts("None");
}

Measured memory_bytes: 3728
from copy import deepcopy as dc

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for h_i in range(2 ** h):
    temp = dc(c)
    for h_j in range(h):
        if (h_i >> h_j) & 1:
            temp[h_j] = ["+"] * w
    for w_i in range(2 ** w):
        temp2 = dc(temp)
        for w_j in range(w):
            if (w_i >> w_j) & 1:
                for i in range(h):
                    temp2[i][w_j] = "+"
        temp_ans = 0
        for i in range(h):
            temp_ans = temp_ans + "".join(temp2[i]).count("#")
        if temp_ans == k:
            ans = ans + 1
print(ans)

Measured memory_bytes: 9344
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
INIT_VAL = 0
def DD2(d1,d2): return [[INIT_VAL]*d2 for _ in range(d1)]
def DD3(d1,d2,d3): return [DD2(d2,d3) for _ in range(d1)]
## math ##
MOD=10**9+7
def divc(x,y): return -(-x//y)
def divf(x,y): return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers"""
    is_prime = [True] * MAX_NUM
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for i in range(MAX_NUM):
        if is_prime[i]:
            primes.append(i)
            for j in range(2*i, MAX_NUM, i):
                is_prime[j] = False
    return primes
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    s = list(IS())
    t = list(IS())
    s = ''.join(sorted(s))
    t = ''.join(sorted(t, reverse=True))
    if s < t: print('Yes')
    else: print('No')


if __name__ == '__main__':
    main()

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

int main() {
	int w, h, x, y, r, a, b, c, d;
	cin >> w >> h >> x >> y >> r;

	/*右下を定義*/
	a = x - r;
	if (a < 0) {
		cout << "No" << endl;
		return 0;
	}
	b = y - r;
	if (b < 0) {
		cout << "No" << endl;
		return 0;
	}

	/*左上を定義*/
	c = x + r;
	if (c > w) {
		cout << "No" << endl;
		return 0;
	}

	d = y + r;
	if (d > h) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 3112
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
int md(int a, int b, int c, int d) {
	return abs(a - c) + abs(b - d);
}
int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H') {
		cout << b;
	}
	else {
		cout << (b == 'H' ? 'D' : 'H');
	}
	return 0;
}




Measured memory_bytes: 256
N, C, K = map(int, raw_input().split())
T = [int(raw_input()) for _ in xrange(N)]

T.sort()
bus = 1
s = T[0]
c = 1
for t in T[1:]:
	if t > s+K or c == C:
		c = 0
		s = t
		bus += 1
	c += 1
print bus

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

int main (){
  
  int N,A;
  
  cin >> N >> A;
  
  N = N % 500;
    
  if (A >= N){
    cout <<"Yes"<< endl;
  }
  else {
    cout <<"No"<< endl;
  }
}

Measured memory_bytes: 256
// VSのおまじない
#define _CRT_SECURE_NO_WARNINGS 0

#include<stdio.h>
#include<stdlib.h>

void problem_a(void);
void problem_b(void);

// メイン関数
int main(void) {
	
	problem_b();

	return 0;
}


void problem_a(void) {
	int a, b;

	//入力
	scanf("%d %d",&a,&b);
	
	// 3匹のヤギが同じ枚数食べられるか？
	if ((a + b) % 3 == 0 || a%3 ==0 || b%3==0) {
		printf("Possible");
	}
	else {
		printf("Impossible");
	}

	return;
}

void problem_b(void) {
	int n,k;
	int *len;
	int sum = 0;
	int i, j;
	

	//入力
	scanf("%d %d", &n, &k);

	//
	len = (int*)malloc(n*sizeof(int));
	for (i = 0; i < n; i++) {
		scanf("%d", &len[i]);
	}

	// 降順ソート
	for (i = 0; i < n - 1; i++) {
		for (j = i + 1; j < n; j++) {
			if (len[i] < len[j]) {
				int temp = len[i];
				len[i] = len[j];
				len[j] = temp;
			}
		}
	}
	
	// 長さの大きいものから足していく
	for (i = 0; i < k; i++) {
		sum += len[i];
	}

	printf("%d", sum);
		
	free(len);
	return;
}

Measured memory_bytes: 128
import java.io.PrintWriter
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (a, b) = nextLongList()
    if (a <= 0 && 0 <= b) {
        println("Zero")
    } else if (0 < a) {
        println("Positive")
    } else {
        val c = b - a + 1
        if (c % 2 == 0L) {
            println("Positive")
        } else {
            println("Negative")
        }
    }
}


Measured memory_bytes: 36416
<?php
list($K) = ints();
$sum6 = 0;
for($i = 1; $i <= $K; $i++)
for($j = 1; $j <= $K; $j++)
$memo[$i][$j] = $memo[$j][$i] = (int)gcd($i, $j);

for($i = 1; $i <= $K; $i++)
for($j = $i+1; $j <= $K; $j++){
    $mij = $memo[$memo[$i][$j]];
    for($k = $j+1; $k <= $K; ++$k)
        $sum6+=$mij[$k];
}

for($i = 1; $i <= $K; $i++){
  $mi = $memo[$i];
  for($j = $i+1; $j <= $K; ++$j)
    $sum6+=$mi[$j];
}

echo $sum6*6+$K*($K+1)/2;

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


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

namespace ABC087_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int B = int.Parse(Console.ReadLine());
            int C = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());

            int count = 0;

            for (int a = 0; a <= A; a++)
            {
                for (int b = 0; b <= B; b++)
                {
                    int temp = X - (a * 500 + b * 100);
                    if (0 <= temp && temp / 50 <= C)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int N = cin.nextInt();
        int[] P = cin.ArrayInt(N);

        int count = 0;

        for (int i = 1; i < N - 1; ++i)
        {
            if (Math.Min(P[i - 1], Math.Min(P[i], P[i + 1])) != P[i] &&
                Math.Max(P[i - 1], Math.Max(P[i], P[i + 1])) != P[i])
            {
                ++count;
            }
        }

        WriteLine(count);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.end()
#define inf 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

typedef pair<int, int> pi;
typedef long long i64;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

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

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

  map<pair<string, string>, int> mp;
  rep(bit, 0, 1 << n) {
    string red = "", blue = "";
    rep(j, 0, n) {
      if(bit & (1 << j)) red += s[j + n];
      else blue += s[j + n];
    }
    mp[make_pair(red, blue)]++;
  }

  i64 ans = 0;
  rep(bit, 0, 1 << n) {
    string red = "", blue = "";
    rep(j, 0, n) {
      if(bit & (1 << j)) red = s[j] + red;
      else blue = s[j] + blue;
    }
    ans += mp[make_pair(blue, red)];
  }
  cout << ans << endl;
}


Measured memory_bytes: 87040
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] a = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int b = sc.nextInt();
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if(a[j][k]==b) a[j][k] = -1;
				}
			}
		}
		int count = 0;
		for (int i = 0; i < 3; i++) {
			if(a[i][0]==-1&&a[i][1]==-1&&a[i][2]==-1) count++;
			if(a[0][i]==-1&&a[1][i]==-1&&a[2][i]==-1) count++;
		}
		if(a[0][0]==-1&&a[1][1]==-1&&a[2][2]==-1) count++;
		if(a[2][0]==-1&&a[1][1]==-1&&a[0][2]==-1) count++;
		if(count>=1) System.out.println("Yes");
		else System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 21844
//??????????????????????????????????????????????????????????????????????????§???????????±????????????????????£??????
/*
?§£???
?????????????????£???????????????????????????????????????
???????????????????????????????????¨??§??????????????\????????°??????????????§?????????????????§????????\????????????????????°?????¨??????????????????????????°???????????????
????????????????????°??????????????????????????°???????????????????¢????????????°???????????????????????????????????°????????????????°???????????????????????????????
?????£?????????????????°????????\?????????????????\????????°????????????????????´????????\??????????±????????????????????????????????????°????????¨?????????
*/
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for (int i=(n)-1;i>=0;i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define REPS(i,f,n) for (int i=(f)-1;i>=(n);i--)

const ll mod = 1000000007;

int main(void){
	ll n; ll t;
	cin >> n >> t;
	vector<ll> d(n);
	rep(i, n) scanf("%lld", &d[i]);

	sort(all(d));
	ll ans = 1;
	//????????\????????´????????¢?????????????????????????¢??????????????????¨??????????????????????????§???????????¢?´¢??¨???lower_bound??¢??°(???????????????"??\???"???????´?????????????????????????????????????)
	//i + 1????????§?????\??£???????????°???????????¨??????????°??????°????????\?????????
	//lower_bound????????£???????????¶????????????????????°???????????????????????¶????????????????????°??????????¨?????¨???????????????¨???(i + 1)??????????????°??????????????°???????????????????????????
	rep(i, n){
		ans = ans * (i + 1 - (ll)(lower_bound(d.begin(), d.begin() + i + 1, d[i] - t) - d.begin())) % mod;
	}

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

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


int main(){
    string S,A,B;
    ll N ,ans = 0;
    cin >> N;
    cin >> S;

    for(ll i = 1; i < N; i++){
        ll tmp_ans = 0;
        vector<ll> a(26,0);
        vector<ll> b(26,0);
        
        A = S.substr(0,i);
        B = S.substr(i, N - i);

        for(int j = 0; j < i; j++) a[A[j] - 'a']++;
        for(int j = 0; j < N - i; j++) b[B[j] - 'a']++;


        for(int j = 0; j < 26; j++){
            if(a[j] > 0 && b[j] > 0) tmp_ans++;
        }
        ans = max(tmp_ans, ans);
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)

    for _ in range(m):
        a, b = map(int, input().split())
        uf.union(a-1, b-1)
    
    sizes = [uf.size(i) for i in range(n)]
    
    print(max(sizes))


if __name__ == '__main__':
    main()


Measured memory_bytes: 89288
N = int(input())
S = input()

A = [0]*N
B = [0]*N

for i in range(1, N):
    A[i] = A[i-1] + (1 if S[i-1]=='W' else 0)
    B[N-i-1] = B[N-i] + (1 if S[N-i]=='E' else 0)

print(min(map(lambda x: x[0]+x[1], zip(A, B))))

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

int main(void)
{
	int a,i,j,ret;
	while(scanf("%d",&a), a){
		ret = 0;
		for(i = 2;i <= 500;i++){
			if ((a << 1) <= i * i)
				break;
			if (!((a << 1) % i) && (((a << 1) / i + i) & 1))
				ret++;
		}
		printf("%d\n",ret);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 998244353;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

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

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct BIT{
  vector<ll> bit;
  int size;
  void init( int n ){
    size = 1;
    while( size < n ) size *= 2;
    bit = vector<ll>( size , 0 );
  }
  void add( int k , ll v ){
    for( int i = k+1; i <= size; i += i & -i ) bit[i-1] += v;
  }
  ll sum( int k ){ // [0,k)
    ll res = 0;
    for( int i = k; i > 0; i -= i & -i ) res += bit[i-1];
    return res;
  }
  ll sum( int l , int r ){ // [l,r)
    return sum( r ) - sum( l );
  }
  ll get( int k ){
    return sum( k+1 ) - sum( k );
  }
  void update( int k , ll x ){
    add( k , x - get(k) );
  }
} bit;


int main(){

  ll n = in();
  ll k = in();
  vector<ll> a(n);
  REP(i, n){
    a[i] = in();
  }
  ll sum = 0;
  REP(i, n){
    sum += a[i];
  }
  vector<vector<bool>> dp(n + 1, vector<bool>(k + 1, false));
  dp[0][0] = true;
  REP(i, n){
    REP(j, k + 1){
      if(dp[i][j]){
        dp[i+1][j] = true;
        if(j + a[i] <= k){
          dp[i+1][j + a[i]] = true;
        }
      }
    }
  }
  vector<vector<bool>> rdp(n + 1, vector<bool>(k + 1, false));
  rdp[n][0] = true;
  for(int i = n-1; i >= 0; i--){
    REP(j, k + 1){
      if(rdp[i+1][j]){
        rdp[i][j] = true;
        if(j + a[i] <= k){
          rdp[i][j + a[i]] = true;
        }
      }
    }
  }
  ll ans = 0;
  REP(i, n){
    bit.init(k + 1);
    REP(j, k+1){
      if(rdp[i+1][j]){
        bit.add(j, 1);
      }
    }
    ll p = k - a[i];
    REP(j, k){
      if(dp[i][j] && (p - j < 0 || bit.sum(p - j, k - j) >= 1)){
        // cout << a[i] << " " << j << endl;
        ans++;
        break;
      }
    }
  }
  cout << n - ans << endl;
  
  return 0;
}


Measured memory_bytes: 7040
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int n,m;cin>>n>>m;

    PQ_DESC_PII pq;
    REP(i,m){
        int a,b;
        cin>>a>>b;
        pq.push(MP(a,b));
    }

    int result = 0;
    int cut=n;
    while(!pq.empty()){
        PII p = pq.top();
        pq.pop();

        if(cut < p.second){
            continue;
        }
        result++;
        cut = p.first;
    }

    cout << result << endl;

	return;
}

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

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    int a = 0, b = 0;

    for(int i = 0; i < (int)s.size(); i ++){
        (((i % 2 == 0) ^ (s[i] == '0')) ? a : b) ++;
    }
    Cout(min(a, b));
}


Measured memory_bytes: 512
#include <vector>
#include <map>
#include <string>
#include <tuple>
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
 
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for (int i=(a); i<(b); ++i)
#define FORD(i,a,b) for (int i=(a)-1; i>=(b); --i)
 
#define pb push_back
#define mp make_pair
#define st first
#define nd second
 
const int MOD = 1000000007;
 
int N;
char S[50];
 
 
map<tuple<int, int, string>, LL> memo;
LL go(int L, int R, string suf) {
  if (suf.size() > R-L) return 0;
  if (L == R) return suf.empty();
 
  auto entry = tuple<int, int, string>(L, R, suf);
  if (memo.find(entry) != memo.end()) return memo[entry];
 
 
  LL result = 0;
  if (!suf.empty()) {
    if (S[L] == suf.back()) {
      result += go(L+1, R, suf.substr(0, suf.size() - 1));
    }
    FOR(i,L+1,R) if (S[L] == S[i]) {
      result += go(L+1,i,string(S+i+1,S+R)+suf);
    }
  } else {
    FOR(i,L+1,R) if (S[L] == S[i]) {
      result += 2*go(L+1,i,string(S+i+1,S+R));
    }
  }
 
  return memo[entry] = result;
}
 
 
int main() {
  // ios_base::sync_with_stdio(0);
 
  scanf("%d", &N);
  N *= 2;
  scanf("%s", S);
  LL result = go(0,N,string());
  printf("%lld\n", result);
 
}

Measured memory_bytes: 256
MOD = pow(10,9)+7
N,K = map(int,input().split())
A = list(map(int,input().split()))
L = [[0,0] for _ in range(N)] #leftとright

for i in range(N): #これが基準
  for j in range(N):
    if A[i] > A[j]:
      if i < j:
        L[i][1] += 1
      elif i > j:
        L[i][0] += 1
#print(L)
ans = 0
for i in range(N):
  left = K*(K-1)//2
  right = K*(K+1)//2
  ans = (ans+L[i][0]*left+L[i][1]*right)%MOD
print(ans)


Measured memory_bytes: 74216
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <string.h>

int main(void) {
    char S[200];
    scanf("%s", S);

    int i;
    int N = strlen(S);
    for(i=0; i<N; i=i+2) {
        if(S[i] != 'R' && S[i] != 'U' && S[i] != 'D') {
            printf("No\n");
            return 0;
        }
    }

    for(i=1; i<N; i=i+2) {
        if(S[i] != 'L' && S[i] != 'U' && S[i] != 'D') {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		string s = Console.ReadLine();
		string t = Console.ReadLine();
		
		int[,] dp = new int[s.Length+1, t.Length+1];
		for(int i = 0; i < s.Length; i++)
		{
			for(int j = 0; j < t.Length; j++)
			{
				if(s[i] == t[j])
				{
					dp[i+1, j+1] = Math.Max(dp[i,j] + 1, dp[i+1, j+1]);
				}
				dp[i+1, j+1] = Math.Max(dp[i+1,j+1], Math.Max(dp[i+1,j], dp[i,j+1]));
			}
		}
		
		int x = s.Length;
		int y = t.Length;
		string r = "";
		while(x > 0 && y > 0)
		{
			int k = dp[x, y];
			if(dp[x-1,y]==k)
			{
				x--;
			}
			else if(dp[x,y-1]==k)
			{
				y--;
			}
			else
			{
				r = s[x-1] + r;
				x--;
				y--;
			}
			
			
		}
		Console.WriteLine(r);
	}
	
	public static long GCD(long a, long b)
	{
		if(b == 1) return a;
		long p = b / a;
		return GCD(a, b - a*p);
	}
	
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		int[] r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
	
}

Measured memory_bytes: 48088
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
using namespace std;

#define ll long long

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a < b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return a / gcd(a, b)*b;

}
//最小公倍数

int main() {

	ll M, N, ans = 0;
	vector<ll> A[8];

	cin >> N >> M;
	for (int i = 0; i < N; i++) {

		ll x, y, z;
		cin >> x >> y >> z;
		A[0].push_back(x + y + z);
		A[1].push_back(x + y - z);
		A[2].push_back(x - y + z);
		A[3].push_back(x - y - z);
		A[4].push_back(0 - x + y + z);
		A[5].push_back(0 - x + y - z);
		A[6].push_back(0 - x - y + z);
		A[7].push_back(0 - x - y - z);

	}
	for (int i = 0; i < 8; i++) {
		sort(A[i].begin(), A[i].end());
		if (i == 0) {
			for (int j = 0; j < M; j++)ans += A[i][N - 1 - j];
		}
		else {
			ll tmp = 0;
			for (int j = 0; j < M; j++)tmp += A[i][N - 1 - j];
			ans = MAX(ans, tmp);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std; 

int main(void){
static long long n,s,dp[102][11][1001];
	
	for(int i=0;i<101;i++)
	  for(int j=0;j<10;j++)
	    for(int k=0;k<1001;k++)
	    dp[i][j][k]=0;
	
  dp[0][0][0] = 1;
 
  for(int i=0;i<101;i++){
    for(int j=0;j<10;j++){
      for(int k=0;k<1001;k++){
        dp[i+1][j][k]+=dp[i][j][k];
 
        if(8<j||1000<k+i) continue;
        dp[i+1][j+1][k+i]+=dp[i][j][k];
      }
    }
  }
 
  while(cin >> n >> s, n|s)
    cout << dp[101][n][s] << endl;
  return 0;
}

Measured memory_bytes: 9808
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;

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

	vector<int>e(1000000, MOD);
	e[0] = 0;
	for (int i = 0; i < 1000000; i++) {
		for (int j = 1; j < 1000; j++) {
			int box = i + j * (j + 1)*(j + 2) / 6;
			if (box >= 1000000)break;
			e[box] = min(e[box], e[i] + 1);
		}
	}
	vector<int>o(1000000, MOD);
	o[0] = 0;
	for (int i = 0; i < 1000000; i++) {
		for (int j = 1; j < 1000; j += 4) {
			int box = i + j * (j + 1)*(j + 2) / 6;
			if (box >= 1000000)break;
			o[box] = min(o[box], o[i] + 1);
		}
	}
	cin >> N;
	while (N) {
		cout << e[N] << " " << o[N] << endl;
		cin >> N;
	}
	return 0;
}


Measured memory_bytes: 10560
def examA():
    N, i = LI()
    ans = N - i + 1
    print(ans)
    return

def examB():
    H, W = LI()
    A = [SI() for _ in range(H)]
    h = [[]for _ in range(H)]
    for i in range(W):
        flag = False
        for j in range(H):
            if A[j][i]=="#":
                flag = True
                break
        if flag:
            for j in range(H):
                h[j].append(A[j][i])
    #print(h)
    ans = []
    for i,a in enumerate(h):
        if "#" in a:
            ans.append(i)
    for v in ans:
        print("".join(map(str,h[v])))
    return

def examC():
    N, K = LI()
    X = LI()
    ans = inf
    for i in range(N-K+1):
        if X[i]<0 and X[i+K-1]>0:
            cur = (-X[i] + X[i+K-1]) + min(-X[i], X[i+K-1])
        else:
            cur = max(-X[i], X[i+K-1])
        ans = min(ans,cur)
    print(ans)
    return

def examD():
    class Bit():
        def __init__(self, n):
            self.size = n
            self.tree = [0] * (n + 1)
            return

        def sum(self, i):
            s = 0
            while i > 0:
                s += self.tree[i]
                i -= i & -i
            return s

        def add(self, i, x):
            while i <= self.size:
                self.tree[i] += x
                i += i & -i
            return
    def inversion_number(n,A):
        bit = Bit(n+1)
        rep = 0
        for i, a in enumerate(A):
            bit.add(a, 1)
            rep += i + 1 - bit.sum(a)
        return rep
    N = I()
    A = LI()
    judge = (N*(N+1)//2 + 1)//2
    l = 0; r = max(A)+1
    while(r-l>1):
        #print(l,r)
        now = (l+r)//2
        S = [0]*(N+1)
        cur = N*(N+1)//2
        for i in range(N):
            if A[i]>=now:
                S[i+1] += 1
            else:
                S[i+1] -= 1
                # cur -= 1
        for i in range(1,N):
            S[i+1] += S[i]
            S[i] += N+1
        S[0] += N+1
        S[N] += N+1
        #print(S)
        cur -= inversion_number(2*N+10,S)
        #print(judge,cur,S,now)
        #print(cur,now)
        #input()
        if cur>=judge:
            l = now
        else:
            r = now

    ans = l
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examD()

"""

"""

Measured memory_bytes: 155984
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
L1 = list(set(s) - set(t))
L2 = list(set(s) & set(t))
ans = 0
for i in L1:
    ans = max(ans, s.count(i))
for j in L2:
    ans = max(ans, s.count(j) - t.count(j))
print(ans)

Measured memory_bytes: 3064