akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC099
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> list = new List<string>();
            while (true)
            {
                string line = Console.ReadLine();
                if (line == null) break;
                list.Add(line);
            }
            var str = list[1].Split(' ');
            List<int> aaa = new List<int>();
            foreach (var item in str)
            {
                aaa.Add(int.Parse(item));
            }

            var sort =aaa.OrderByDescending(Z => Z);
            int chk = sort.First();
            int result = 0;
                foreach (var item in sort.Select((Value, Index) => new { Value, Index }))
	            {
                    if (item.Index!=0)
                    {
                        result = result + item.Value;
                    }
	            }
                if (chk<result)
                {
                    Console.WriteLine("Yes");
                }else
                {
                    Console.WriteLine("No");
                }
        }

    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
 
typedef int ll;
 
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'
 
typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;
 
const int mod=1e9+7;
 
int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}
 
void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}
 
int gcd(int a, int b) {
   if (b == 0)
   return a;
   return gcd(b, a % b);
}
 
ll main() {
	// freopen("Task.in", "r", stdin);freopen("Task.out", "w", stdout);

	int n;
	cin>>n;

	vector<int>v;

	for (int i=0; i<n; i++) {
		int x;
		cin>>x;

		v.pb(x);
	}

	int ret=0;
	for (int i=1; i<n; i++) {
		if(v[i]<v[i-1]) {
			ret+=(v[i-1]-v[i]);
			v[i]=v[i-1];
		}
	}

	cout<<ret<<endl;
}

Measured memory_bytes: 5296
var permList = mutableListOf<String>()

fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    val PN = readLine()!!.split(" ").joinToString("")
    val QN = readLine()!!.split(" ").joinToString("")

    perm(N)

    val a = permList.indexOf(PN) + 1
    val b = permList.indexOf(QN) + 1

    println(Math.abs(a - b))
}

fun perm(n: Int){
    val c = (1..n).toList()
    val p = emptyList<Int>()
    perm(c, p)
}

fun perm(c: List<Int>, p: List<Int>) {
    if (c.isEmpty()) {
        permList.add(p.joinToString(""))
        return
    }
    for (e in c) {

        val newC = c.minusElement(e)
        val newP = p.plusElement(e)

        perm(newC, newP)
    }
}

Measured memory_bytes: 48284
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <limits>

using namespace std;

int N;
size_t MASK;
vector<vector<int>> v;
vector<vector<int>> dp;

size_t get_mask()
{ 
  size_t mask = 0;
  for (int i = 0; i < N; ++i)
  { 
    mask |= (1 << i);
  }
  return mask;
}

size_t add(size_t res, size_t delta)
{ 
  return (res + delta) % 1000000007;
}

size_t solution(int i, size_t mask = 0)
{ 
  size_t res = 0;
  { 
    for (int j = 0; j < N; ++j)
    { 
      if (v[i][j] && !(mask & (1<<j)))
      { 
        if ((mask | (1<<j)) == MASK)
        { 
          res = add(res, 1);
          continue;
        }
        if (dp[i+1][mask | (1<<j)] == -1)
        { 
          dp[i+1][mask | (1<<j)] = solution(i+1, mask | (1<<j));
        }
        res = add(res, dp[i+1][mask | (1<<j)]);
      } 
    }
  }
  return res;
}

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

  cin >> N;

  MASK = get_mask();

  v = vector<vector<int>>(N, vector<int>(N));
  dp = vector<vector<int>>(N+1, vector<int>(1<<N, -1));

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

  cout << solution(0);

  return 0;
}

Measured memory_bytes: 188800
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

class TRIE{
  constructor(){
    this.tree = [{last:false}];
  }
  search(s){
    var id = 0, tr = this.tree;
    for(var i = 0; i < s.length; i++){
      if(tr[id][s[i]] === undefined)return false;
      id = tr[id][s[i]];
    }
    return tr[id].last;
  }
  add(s){
    var id = 0, tr = this.tree, i = 0;
    for(; i < s.length; i++){
      if(tr[id][s[i]] === undefined)break;
      id = tr[id][s[i]];
    }
    for(; i < s.length; i++){
      id = tr[id][s[i]] = tr.length;
      tr.push({last:false});
    }
    tr[id].last = true;
  }
  searchAndAdd(s){
    var id = 0, tr = this.tree, i = 0;
    for(; i < s.length; i++){
      if(tr[id][s[i]] === undefined)break;
      id = tr[id][s[i]];
    }
    if(i === s.length){
      if(tr[id].last)return true;
      tr[id].last = true;
      return false;
    }
    for(; i < s.length; i++){
      id = tr[id][s[i]] = tr.length;
      tr.push({last:false});
    }
    tr[id].last = true;
    return false;
  }
  next(id,s){
    var tr = this.tree;
    if(tr[id][s] === undefined){
      id = tr[id][s] = tr.length;
      tr.push({last:false});
    }else id = tr[id][s];
    return id;
  }
}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var s = nexts(n,1).map(a=>a.split("").reverse().map(a=>a.charCodeAt()-97)).sort((a,b)=>a.length-b.length);
  var ans = 0;
  var st = {};
  var tr = new TRIE();
  var az = xArray(0,26);
  for(var i = 0; i < n; i++){
    var t = s[i];
    var id = 0;
    for(var j = 0; j < t.length-1; j++){
      if(st[id])for(var k = 0; k < st[id].length; k++){
        az[st[id][k]]++;
      }
      if(az[t[j]])ans += az[t[j]], az[t[j]] = 0;
      id = tr.next(id,t[j]);
    }
    if(az[t[j]])ans += az[t[j]], az[t[j]] = 0;
    if(st[id])st[id].push(t[j]);else st[id] = [t[j]];
    az = az.fill(0);
  }
  return ans;
}

Measured memory_bytes: 428012
import java.io.*;
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main
{
	public static void main(String []args)throws IOException
	{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String S = br.readLine();
		int len = S.length();
		for(int i=0;i<len;i++)
			out.print("x");
		out.println();
		
	}
}




Measured memory_bytes: 22100
#include <stdio.h>

int compare(const void *a, const void *b) {
	int *A = (int*)a;
	int *B = (int*)b;
	if((*A % 10) > (*B % 10)) return 1;
	if((*A % 10) < (*B % 10)) return -1;
	return 0;
}

int main() {
	int input[5];
	int sum = 0;
	int i;

	for(i = 0; i < 5; i++) {
		scanf("%d", &input[i]);
	}

	for(i = 0; i < 5; i++) {
		if(input[i] % 10 == 0) {
			sum += input[i];
			input[i] = 0;
		}
	}

	qsort(input, 5, sizeof(int), compare);

	for(i = 0; i < 5; i++) {
		if(input[i] % 10 > 0) {
			sum += input[i];
			input[i] = 0;
			break;
		}
	}

	for(i = 0; i < 5; i++) {
		if(input[i] % 10 > 0) {
			sum += input[i] - (input[i] % 10) + 10;
		}
	}

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

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
int main()
{
    int n;
    cin >> n;
    set<int> st;
    for(int i = 0; i < n; i++){
        int d; cin >> d;
        st.insert(d);
    }
    cout << st.size() << endl;
    return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> p(N+1);
    rep(i, 1, N+1) cin >> p[i];
    ll i = 1, ans = 0;
    while(i <= N){
        if(p[i] == i){
            ans++;
            i++;
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int X,r=0;
    cin >> X;

    rep(i,1000)
        rep(j,1000) {
            int t = pow(i+1,j+2);
            if(t > X)
                break;
            r = max(r,t);
        }

    cout << r << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

template<typename T>
void read(T &n){
    n = 0;
    T f = 1;
    char c = getchar();
    while(!isdigit(c) && c != '-') c = getchar();
    if(c == '-') f = -1, c = getchar();
    while(isdigit(c)) n = n*10+c-'0', c = getchar();
    n *= f;
}
template<typename T>
void write(T n){
    if(n < 0) putchar('-'), n = -n;
    if(n > 9) write(n/10);
    putchar(n%10+'0');
}

int n, a[MAX];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++){
        read(a[i]);
    }
    int ans = (int)1e9;
    for(int i = 1; i <= 100; i++){
        int s = 0;
        for(int j = 1; j <= n; j++){
            s += (a[j]-i)*(a[j]-i);
        }
        ans = min(ans, s);
    }
    cout << ans << endl;

    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int N; cin >> N;
	vint D(N); cin >> D;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += D[i] * D[j];
		}
	}
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    ll a[n];
    rep(i, 0, n) cin >> a[i];
    ll sum[n + 1] = {};
    rep(i, 0, n) {
        sum[i + 1] = sum[i] + a[i];
    }

    map<ll, ll> mp;
    rep(i, 1, n + 1) mp[sum[i] % m]++;
    ll ans = 0;
    for (auto i : mp) {
        if(i.first == 0) ans += i.second;
        ans += i.second * (i.second - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 100000000

int main() {
	int n, m;
	scanf("%d %d", &m, &n);
	int maxv = 0;
	rep(i,m) {
		int s = 0;
		rep(j,n) {
			int t;
			scanf(" %d", &t);
			if(t == 1) {
				s++;
			}
		}
		maxv = max<int>(s, maxv);
	}
	printf("%d\n", maxv);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
ll gcd(ll b, ll c){
    return c ? gcd(c, b%c) : b;
}

ll lcm(ll b, ll c){
    return b/gcd(b,c)*c;
}

ll f(ll x, ll b, ll c){
    ll res = x;
    res -= x/b;
    res -= x/c;
    res += x/lcm(b,c);
    return res;
}
int main() {
    long long A,B,C,D;
    cin >> A >> B >>C >>D;
    ll ans = f(B,C,D) - f(A-1,C,D);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define ll long long
using namespace std;
const int N=5e5+5;
int n,m,i,h,t,qv[N];
double ans;
double qt[N];
int read(){
	char c=getchar();int k=0;for (;c<48||c>57;c=getchar());
	for (;c>47&&c<58;c=getchar()) k=(k<<3)+(k<<1)+c-48;return k;
}
int main(){
	n=read();m=read();h=1;
	for (i=1;i<=n;i++){
		double tem=read();int v=read(),nv=v;
		for (;h<=t&&qv[h]<=nv;h++)
			ans-=qv[h]*qt[h],nv-=qv[h];
		if (nv) ans-=nv*qt[h],qv[h]-=nv;
		ans+=v*tem;
		for (;h<=t&&qt[t]>tem;t--)
			tem=(v*tem+qv[t]*qt[t])/(v+qv[t]),v+=qv[t];
		qv[++t]=v;qt[t]=tem;
		printf("%.7lf\n",ans/m);
	}
}

Measured memory_bytes: 14848
K,N = map(int,input().split())
A = list(map(int,input().split()))

dis = A[0] + (K-A[N-1])

for i in range(1,N):									#range(始まり、項数)
	dis = max(dis,A[i]-A[i-1])

dis = K - dis
print(dis)

Measured memory_bytes: 26420
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)

const int INF = 100000000;

using namespace std;


int main() {
	int x;
	cin >> x;
	if (x >= 1200)cout << "ARC" << endl;
	else cout << "ABC" << endl;

	return 0;
}

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


int main(){
	    ll K, N; cin >> K >> N;
        vector<ll> A(N);
        rep(i, N) cin >> A[i];

        ll ans = min(A[N-1] - A[0], K - A[1] + A[0]);
        for(int i = 1; i < N-1; ++i){
            ans = min({ans, K - A[i] + A[i-1], K - A[i+1] + A[i]});
        }
        cout << ans << endl;
}


Measured memory_bytes: 1920
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

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

#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 5e3+5;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

int n, k;

int p[maxn];

int c[maxn];

vector< vi > cc;

bool vis[maxn];

void dfs(int u)
{
	if(vis[u]) return;
	cc.back().pb(c[u]);
	vis[u] = true;
	dfs(p[u]);
}

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

	for(int i = 1; i<= n; i++) scanf("%d", &p[i]);
	for(int i = 1; i<= n; i++) scanf("%d", &c[i]);

	for(int i = 1; i<= n; i++)
	{
		if(vis[i]) continue;
		cc.pb(vi());
		dfs(i);
	}

	ll best = -4e18;

	for(vi foo : cc)
	{
		int m = foo.size();
		for(int i = 0; i< m; i++)
		{
			vector<ll> vals(m+1);
			vals[0] = -4e18;
			ll sum = 0;
			for(int j = 0; j< m; j++)
			{
				int cur = (i+j)%m;
				sum += foo[cur];
				vals[j+1] = max(vals[j], sum);
			}
			best = max(best, vals[min(m, k)]);
			if(k> m)
			{
				best = max(best, sum*(k/m)+max(0LL, vals[k%m]));
				best = max(best, sum*(k/m-1)+max(0LL, vals[m]));
			}
		}
	}
	printf("%lld\n", best);
}

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

int main() {
    int A;
    cin >> A;
    int B;
    cin >> B;
    int i=0;
    for(;;){
        if(i *(A -1) +1 < B){
            ++i;
        }else{
            break;
        }

    }
    cout << i << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int k=sc.nextInt();
    int x=sc.nextInt();
    if(k*500>=x){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define dbg(x) cerr<<#x<<" = "<<x<<endl;
#define dbg_v(v,n) {cerr<<#v<<" = [";for(int III=0;III<=n;III++)cerr<<v[III]<<(III!=n?",":"]\n");}
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define Nmax 1005
using namespace std;

int n,m,a,b,cb,ca,_free,sp,x,y,aiurea,b2,bulan;
int px,py = -2;
char mat[Nmax][Nmax];

void getFree(int &px, int &py){
	py += 2;
	if (m - py < 2){
		px+=2;
		py = 0;
	}
}

void solve(int A, int B){

	for (int i=0;i<n;i++)
		for (int j=0;j<m;j++)
			mat[i][j] = '.';

	if (bulan){
		mat[n-3][m-3] = '<';
		mat[n-3][m-2] = '>';
		mat[n-3][m-1] = '^';
		mat[n-2][m-3] = '^';
		mat[n-2][m-1] = 'v';
		mat[n-1][m-3] = 'v';
		mat[n-1][m-2] = '<';
		mat[n-1][m-1] = '>';
	}

	for(int i=2;i<=A;i+=2){
		getFree(px, py);
		mat[px][py] = '<';
		mat[px][py+1] = '>';
		mat[px+1][py] = '<';
		mat[px+1][py+1] = '>';
	}
	if (A % 2){
		getFree(px, py);
		mat[px][py] = '<';
		mat[px][py+1] = '>';
	}
	for (int i=2;i<=B;i+=2){
		getFree(px, py);
		mat[px][py] = '^';
		mat[px+1][py] = 'v';
		mat[px][py+1] = '^';
		mat[px+1][py+1] = 'v';
	}
	if (B % 2){
		getFree(px, py);
		mat[px][py] = '^';
		mat[px+1][py] = 'v';
	}

	a -= A;
	b -= B;
	px = n - 1;
	py = 0;
	for (int i=1;i<=a;i++){
		mat[px][py] = '<';
		mat[px][py+1] = '>';
		assert(py+1 < m);
		py += 2;
	}
	px = 0;
	py = m-1;
	for (int i=1;i<=b;i++){
		mat[px][py] = '^';
		mat[px+1][py] = 'v';
		assert(px+1 < n);
		px += 2;
	}
	cout << "YES\n";
	for (int i=0;i<n;i++)
		cout << mat[i] << '\n';
	exit(0);
}

int main(){
    ios::sync_with_stdio(false);
    cin >> n >> m >> a >> b; 
    
    x = n / 2;
    y = m / 2;
    int mx = x * y;
    if (n%2) ca = m / 2;
    if (m%2) cb = n / 2;
    for (int i=0;i<=a;i++){
    	sp = i / 2 + i % 2;
    	if (sp > mx) continue;
    	_free = mx - sp;
    	if (b / 2 + b % 2 <= _free) b2 = 0;
    	else b2 = b - (_free * 2);
    		
    	if (a-i <= ca && b2 <= cb){
    		solve(i, b - b2);
    	}
    }
    if (n%2 && m%2 && a >= 2 && b >= 2 && ca && cb && mx){
    	mx--;
    	ca--;
    	cb--;
    	bulan = 1;
    	a -= 2;
    	b -= 2;
    }
    for (int i=0;i<=a;i++){
    	sp = i / 2 + i % 2;
    	if (sp > mx) continue;
    	_free = mx - sp;
    	if (b / 2 + b % 2 <= _free) b2 = 0;
    	else b2 = b - (_free * 2);
    		
    	if (a-i <= ca && b2 <= cb){
    		solve(i, b - b2);
    	}
    }
    cout << "NO\n";

    return 0;
}

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

using namespace std;

int main() {
	#if LOCAL
	freopen("a.in", "r", stdin);
	#endif
	int W,H,w,h;
	cin>>W>>H>>w>>h;
	cout<<(W*H)-(w*H+h*W-w*h)<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>

#define rep(i,x) for(int i = 0; i < x; i++)
#define rrep(i,x) for(int i = 1; i <= x; i++)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using ll = long long;
using namespace std;
const int INF = 1001001001;
const ll LINF = 1002003004005006007;

int main(){
    int n; cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    int ans = 0, mini = p[0];
    rep(i, n){
        if (p[i] <= mini) ans++;
        mini = min(mini, p[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
 
int main(){
    bool ans=1;
    int j=0;
    string N; cin>>N;
    if(N.at(1)==N.at(2)){
        if(N.at(0)!=N.at(1)&&N.at(3)!=N.at(1))ans=0;
    }else{
      ans=0;
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

ll Q;
multiset<ll> all;
ll com, x, y;
ll ans, cnt;
int main(){
    cin >> Q;
    cin >> com >> x >> y;
    all.insert(x);
    ans = y;
    cnt++;
    auto mid = all.begin();
    for(int i = 0; i < Q - 1; i++){
        cin >> com;
        if(com == 1){
            cin >> x >> y;
            if(x >= *mid && cnt % 2 == 0){
                all.insert(x);
                mid++;
                ans += x - *mid;
            }
            else if(x < *mid && cnt % 2 == 1){
                all.insert(x);
                ans += *mid - x;
                mid--;
            }
            else if(x < *mid && cnt % 2 == 0){
                all.insert(x);
                ans += *mid - x;
            }
            else{
                all.insert(x);
                ans += x - *mid;
            }
            cnt++;
            ans += y;
        }else cout << *mid << " " << ans << endl;
    }
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
const int N = 2 * 1e5 + 5;
const ll mod = 1e9 + 7;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
//freopen("","r",stdin);
//freopen("","w",stdout);
ll POW(ll a,ll b,ll mod){
    ll ans = 1;
    while(b){
        if(b & 1)
            ans = (ans % mod * a % mod) % mod;
        b >>= 1;
        a = (a % mod * a % mod) % mod;
    }
    return ans;
}
ll combi(ll n,ll k){
  k=min(k,n-k);
  ll ans=1;
  ll ans2 = 1;
  //usa prop matematica c(n,r)=(n*(n-1)*..*1)/(r!*(n-r)!)
  //se cancelan el (n-r)! con el del numerador
  for(ll i=0;i<k;i++){

    //ans = (ans % mod * (n - i + mod) % mod) % mod;
    ans = (ans % mod * (n - i + mod) % mod) % mod;
    //cout<<ans<<" mult ans \n";
    ans2 = (ans2 % mod * (i + 1) % mod) % mod;
    //ans = (ans % mod * POW(i + 1,euler(i + 1) - 1, mod)) % mod;    //cout<<ans<<" div ans \n";
  }
  return (ans * POW(ans2,1000000005,mod)) % mod;
}
int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    cout << (POW(2,n,mod) - 1 + mod - combi(n,a) + mod - combi(n,b) + mod) % mod;
    return 0;
}

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

using namespace std;

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

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

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	cout << fixed << setprecision(10);
	ll w, h;
	int x, y;
	cin >> w >> h >> x >> y;
	cout << ((double)w * h / 2) << " ";
	if ((x == w / 2 && y == h / 2) && (w % 2 == 0 && h % 2 == 0)) cout << 1 << endl;
	else cout << 0 << endl;
    
    return 0;
}



Measured memory_bytes: 3724
#include <stdio.h>
#define MAX 100

int main(){
  int n,i,j,u,k,v;
  int A[MAX][MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      A[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0) printf(" ");
      printf("%d",A[i][j]);
    }
    printf("\n");
  }

  return 0;
}

      

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

long double calc(int a,int b,int c,int d){
    return sqrt(abs(a - b) * abs(a - b) + abs(c - d) * abs(c - d));
}

int fact(int N){
    int re = 1;
    for (int i = 2; i <= N;i++)
    {
        re *= i;
    }
    return re;
}
int main(){
    int N;
    cin >> N;
    vector<ll> X(N);
    vector<ll> Y(N);
    for (int i = 0; i < N;i++)
    {
        cin >> X[i] >> Y[i];
    }
     long double ans = 0.0;
    for (int i = 0; i < N;i++)
    {
        for (int j = i + 1; j < N;j++)
        {
            ans += calc(X[i], X[j], Y[i], Y[j]);
        }
    }
    long double pre = (long double)N / 2;
    ans = ans / pre;
    cout << fixed << ans << setprecision(16)<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

void solve()
{
	int n;
	string str;
	cin >> n >> str;

	int answ = 0;

	for(int start = 0; start < n; ++start)
	{
		string suff;

		for(int i = start; i < n; ++i)
			suff.push_back(str[i]);

		int m = len(suff);
		vector<int> z(m, 0);
		int l = NIL, r = NIL;

		for(int i = 1; i < m; ++i)
		{
			if(i <= r)
				z[i] = min(r - i + 1, z[i - l]);

			while(i + z[i] < m && suff[i + z[i]] == suff[z[i]])
				++z[i];

			if(i + z[i] - 1 >= r)
				l = i, r = i + z[i] - 1;
		}

		for(int i = 0; i < m; ++i)
			answ = max(answ, min(i, z[i]));
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 384
import sys
import heapq as hq

readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

n = ni()
l = [ns() for _ in range(n)]
gu = list()
gd = list()
c = 0
lm = None
for i in range(n):
    s = l[i]
    t = 0
    m = 0
    for x in s:
        if x == '(':
            t += 1
        else:
            t -= 1
            if m > t:
                m = t
    c += t
    if t > 0:
        gu.append((m, t))
    else:
      if t == m and (lm is None or m < lm):
        t = lm
        m, lm = lm, m
      if m is not None:
        gd.append((m, -t))
if c != 0 or lm is None:
    print('No')
    exit(0)
gu.sort(reverse=True)
gd.sort()
cur = 0
q = list()
for m, t in gu:
    if cur + m < 0:
        print('No')
        exit(0)
    cur += t
for m, t in gd:
    if cur + m < 0:
        print('No')
        exit(0)
    cur -= t

print('Yes')


Measured memory_bytes: 88116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int A,B;
    cin >> A >> B;
    if(A*B == 2){
        cout << 3 << endl; 
    }else if(A*B == 3){
        cout << 2 << endl;
    }else if(A*B == 6){
        cout << 1 << endl;
    }
    return 0;
}

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

int main()
{
    string goal = "##.##"
                  "#abc#"
                  "defgh"
                  "#ijk#"
                  "##.##";

    vector<int> pos(256);
    for(int i=0; i<25; ++i){
        if(goal[i] != '#' && goal[i] != '.')
            pos[goal[i]] = i;
    }

    int d[] = {5, -5, 1, -1};

    for(;;){
        string s(25, '#');
        for(int i=0; i<25; ++i){
            if(goal[i] == '#')
                continue;
            int a;
            cin >> a;
            if(a == -1)
                return 0;
            if(a == 0)
                s[i] = '.';
            else
                s[i] = 'a' + a - 1;
        }

        if(s == goal){
            cout << 0 << endl;
            continue;
        }

        set<string> history;
        history.insert(s);
        vector<string> curr(1, s);

        int ret = -1;
        for(int i=0; i<20; ++i){
            vector<string> next;
            for(unsigned j=0; j<curr.size(); ++j){
                int len = 0;
                for(int k=0; k<25; ++k){
                    if(curr[j][k] != '#' && curr[j][k] != '.')
                        len += abs(k/5 - pos[curr[j][k]]/5) + abs(k%5 - pos[curr[j][k]]%5);
                }
                if(len > 20 - i)
                    continue;

                for(int k=0; k<25; ++k){
                    if(curr[j][k] != '.')
                        continue;
                    for(int l=0; l<4; ++l){
                        if(l < 2 && (k+d[l] < 0 || k+d[l] >= 25))
                            continue;
                        if(l >= 2 && (k+5) / 5 != (k+d[l]+5) / 5)
                            continue;
                        if(curr[j][k+d[l]] == '#')
                            continue;
                        swap(curr[j][k], curr[j][k+d[l]]);
                        if(history.find(curr[j]) == history.end()){
                            if(curr[j] == goal)
                                ret = i + 1;
                            history.insert(curr[j]);
                            next.push_back(curr[j]);
                        }
                        swap(curr[j][k], curr[j][k+d[l]]);
                    }
                }
            }
            curr.swap(next);
            if(ret != -1)
                break;
        }

        if(ret == -1)
            cout << "NA" << endl;
        else
            cout << ret << endl;
    }
}

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

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if(s.at(0) < t.at(0)) {
        printf("Yes");
        return 0;
    }
    if(s.at(0) == t.at(0) && s.size() < t.size() && s.size() > 1) {
        for(int i = 1; i < s.size(); i++) {
            if(s.at(i) < t.at(i)) {
                printf("Yes");
                return 0;
            }
        }
    } else if (s.at(0) == t.at(0) && s.size() > t.size() && t.size() > 1) {
		for(int i = 1; i < t.size(); i++) {
            if(s.at(i) < t.at(i)) {
                printf("Yes");
                return 0;
            }
        }
    }
    if(s == t.substr(0, s.size()) && s.size() < t.size()) {
    	printf("Yes");
        return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 256
Scanf.sscanf (read_line ()) "%d %d" (fun h w ->
    let s = Array.init h (fun _ -> Bytes.of_string @@ read_line ()) in
    for y = 0 to h - 1 do
        for x = 0 to w - 1 do
            if Bytes.get s.(y) x = '.' then (
                let acc = 0 in
                let acc = if y > 0     && x > 0     && Bytes.get s.(y - 1) (x - 1) = '#' then acc + 1 else acc in
                let acc = if y > 0                  && Bytes.get s.(y - 1) (x)     = '#' then acc + 1 else acc in
                let acc = if y > 0     && x < w - 1 && Bytes.get s.(y - 1) (x + 1) = '#' then acc + 1 else acc in
                let acc = if              x > 0     && Bytes.get s.(y)     (x - 1) = '#' then acc + 1 else acc in
                let acc = if              x < w - 1 && Bytes.get s.(y)     (x + 1) = '#' then acc + 1 else acc in
                let acc = if y < h - 1 && x > 0     && Bytes.get s.(y + 1) (x - 1) = '#' then acc + 1 else acc in
                let acc = if y < h - 1              && Bytes.get s.(y + 1) (x)     = '#' then acc + 1 else acc in
                let acc = if y < h - 1 && x < w - 1 && Bytes.get s.(y + 1) (x + 1) = '#' then acc + 1 else acc in
                Bytes.set s.(y) x (char_of_int (acc + 48))
            )
        done
    done;
    for y = 0 to h - 1 do
        print_endline @@ Bytes.to_string s.(y)
    done
)

Measured memory_bytes: 384
num = int(input())
num = num % 10

if num == 2 or num == 4 or num == 5 or num == 7 or num == 9:
    print('hon')
elif num == 0 or num == 1 or num == 6 or num == 8:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 9100
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<string> s(n);
    vector<int> cnt(n);
    int a=0,b=0,ab=0;
    int ans=0;
    rep(i,n){
        cin>>s.at(i);
        int tmp=0;
        rep(j,s.at(i).size()-1){
            if(s.at(i).at(j)=='A' and s.at(i).at(j+1)=='B'){
                tmp++;
            }
        }
        cnt.at(i)=tmp;
        ans+=tmp;
        if(s.at(i).front()=='B' and s.at(i).back()=='A')ab++;
        else if(s.at(i).front()=='B')b++;
        else if(s.at(i).back()=='A')a++;
    }
    if(ab>0)ans+=ab-1;
    if(a>0 and ab>0){
        ans++;
        a--;
    }
    if(b>0 and ab>0){
        ans++;
        b--;
    }
    ans+=min(a,b);
    cout<<ans<<endl;
}



Measured memory_bytes: 896
import java.util.*;

public class Main {
  // constant
  static long MAX_LONG = Long.MAX_VALUE;

  // global variables
  static long[] dists;

  // inner classes
  static class NBR {
    int bi;
    long ti;

    NBR(int bi, long ti) {
      this.bi = bi;
      this.ti = ti;
    }
  }

  static class QComp implements Comparator<Integer> {
    public int compare(Integer int0, Integer int1) {
      int i0 = int0.intValue();
      int i1 = int1.intValue();
      long cmpd = dists[i0] - dists[i1];
      if (cmpd < 0) return -1;
      if (cmpd > 0) return 1;
      return  i0 - i1;
    }
  }

  // main
  public static final void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();
    long x = sc.nextLong();

    long[] hs = new long[n];
    for (int i = 0; i < n; i++)
      hs[i] = sc.nextInt();

    ArrayList<ArrayList<NBR>> nbrs = new ArrayList<ArrayList<NBR>>();
    for (int i = 0; i < n; i++)
      nbrs.add(new ArrayList<NBR>());

    for (int i = 0; i < m; i++) {
      int ai = sc.nextInt() - 1;
      int bi = sc.nextInt() - 1;
      long ti = sc.nextLong();

      nbrs.get(ai).add(new NBR(bi, ti));
      nbrs.get(bi).add(new NBR(ai, ti));
    }

    dists = new long[n];
    Arrays.fill(dists, MAX_LONG);
    dists[0] = 0;

    PriorityQueue<Integer> q = new PriorityQueue<Integer>(n / 2, new QComp());
    q.add(0);

    while (! q.isEmpty()) {
      Integer ui = q.poll();
      int u = ui.intValue();

      if (u == n - 1) continue;

      long du = dists[u];
      long xu = x - du;
      if (xu < 0) xu = 0;
      long hu = hs[u];

      for (NBR vnbr: nbrs.get(u)) {
        int v = vnbr.bi;
        long dv = du + vnbr.ti;
        long xv = xu - vnbr.ti;

        if (xv < 0) {
          if (xu + -xv > hu) continue;
          dv += -xv;
        }
        else if (xv > hs[v]) {
          dv += xv - hs[v];
        }

        if (dists[v] > dv) {
          if (dists[v] < MAX_LONG) q.remove(v);
          dists[v] = dv;
          q.add(v);
        }
      }
    }

    long dg = dists[n - 1];

    if (dg >= MAX_LONG)
      dg = -1;
    else {
      long xg = x - dg;
      if (xg < 0) xg = 0;
      dg += hs[n - 1] - xg;
    }

    System.out.println(dg);
  }
}

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

using namespace std;
typedef long long ll;

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

int main()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w) << '\n';
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

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

using namespace std;

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

int n,ans,ansbuf;
char buf;
int main() {
    cin>>n;
    int s[n];
    REP(i,n){
        cin>>buf;
        if(buf=='W'){
            s[i]=0;
        }else{
            s[i]=1;
            if(i!=0){
                ansbuf++;
            }
        }
    }
    ans=ansbuf;
    REP(i,n-1){
        if(s[i]==0){
            ansbuf++;
        }
        if(s[i+1]==1) ansbuf--;
        ans=min(ans,ansbuf);
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (int i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;


int main(){

  int n,i;cin>>n>>i;

  out(n+1-i);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c[20],a[20][20],sum[20],ans=99999999,kk;
int n,m,x;
void dfs(int xx){
	int i,j,k,l;
	kk+=c[xx];
	for(i=1;i<=m;i++)sum[i]+=a[xx][i];
	int fl=0;
	for(i=1;i<=m;i++){
		if(sum[i]<x){
			fl=1;break;
		}
	}
	if(!fl)ans=min(ans,kk);
	else{
		for(i=xx+1;i<=n;i++){
			dfs(i);
			kk-=c[i];
			for(j=1;j<=m;j++)sum[j]-=a[i][j];
		}
	}
}
int main(){
	int i,j,k,l;
	cin>>n>>m>>x;
	for(i=1;i<=n;i++){
		cin>>c[i];
		for(j=1;j<=m;j++){
			cin>>a[i][j];
			sum[j]+=a[i][j];
		}
	}
	for(i=1;i<=m;i++){
		if(sum[i]<x){
			cout<<"-1";return 0;
		}
	}
	memset(sum,0,sizeof(sum));
	for(i=1;i<=n;i++){
		dfs(i);
		kk-=c[i];
		for(j=1;j<=m;j++)sum[j]-=a[i][j];
	}
	cout<<ans;
} 

Measured memory_bytes: 3624
a = int(input())
s = {}
for i in range(a):
    tmp = input()
    if tmp in s:
        s[tmp] += 1
    else:
        s[tmp] = 1

b = int(input())
t = {}
for i in range(b):
    tmp = input()
    if tmp in t:
        t[tmp] += 1
    else:
        t[tmp] = 1

ans = 0
for key, value in s.items():
    ans = max(value - t.get(key, 0), ans)

print(ans)

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

int main(){
    int n, x;
    int sum = 0, count;
    while(1){
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        count = 0;
        for (int i = 1; i <= n - 2 ; i++){
            for (int j = i + 1; j <= n - 1; j++){
                for (int k = j + 1; k <= n; k++){
                    sum = i + j + k;
                    if (sum == x) count ++;
                } 
            }
        }
    cout << count << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define N 20004
#define x first
#define y second
using namespace std;
int M=1<<15;
int offset=1<<14;

int n;
pair<int,int> p[N*2];
struct edge{
	int t,next;
}e[2000005];int ecnt,head[(1<<17)+N*4];
int tag;
void addedge(int f,int t){
	if(tag==233) cout<<f<<" "<<t<<endl;
	e[++ecnt]=(edge){t,head[f]};head[f]=ecnt;
	e[++ecnt]=(edge){f^1,head[t^1]};head[t^1]=ecnt;
}
void add(int id,int l,int r){
	if(l>r) return;
	for(l=l+offset-1,r=r+offset+1;l^r^1;l>>=1,r>>=1){
		if(l&1^1) addedge(id,(l^1)<<1);
		if(r&1) addedge(id,(r^1)<<1);
	}
}
int colored;
int vis[(1<<17)+N*4];
#define lowb(val) (lower_bound(p,p+n*2,make_pair(val,-1))-p+1)
void build(int val){
	if(val==-1)
		tag=233;
	memset(vis,0,sizeof(vis));
	ecnt=colored=0;
	memset(head,0,sizeof(head));
	for(int i=0;i<n*2;i++)
		addedge((offset+i+1)*2,p[i].y^1);
	for(int i=1;i<offset;i++)
		addedge(i*2,(i<<1)*2),
		addedge(i*2,(i<<1|1)*2);
		
	for(int i=0;i<n*2;i++)
		add(p[i].y,lowb(p[i].x-val+1),i-1+1),
		add(p[i].y,i+1+1,lowb(p[i].x+val)-1);
}

bool DFS(int u,int c){
	vis[u]=c;
	for(int i=head[u];i;i=e[i].next)
		if(vis[e[i].t]==0)
			if(!(vis[e[i].t^1]==0&&DFS(e[i].t,c)))
				return false;
	return true;
}
void clean(int u,int c){
	vis[u]=0;
	for(int i=head[u];i;i=e[i].next)
		if(vis[e[i].t]==c)
			clean(e[i].t,c);
}
bool check(int val){
	build(val);
	for(int i=0;i<(M+n)*2;i++)
		if(vis[i]==0&&vis[i^1]==0){
			if(DFS(i,colored+1)) colored++;
			else {
				clean(i,colored+1);
				if(!DFS(i^1,colored+1)) return false;
				else colored++;
			}
		}
	return true;
}
#define id(x,pos) (((M)+(x))<<1|(pos))
int main(){	
	scanf("%d",&n);
	offset=1;while(offset<n*2+2) offset<<=1;
	M=offset<<1;
	
	for(int i=0;i<n;i++){
		pair<int,int> a,b;
		scanf("%d%d",&a.x,&b.x);
		a.y=id(i,0);b.y=id(i,1);
		p[i*2]=a,p[i*2+1]=b;
	}
	sort(p,p+n*2);
	
	int l=0,r=1e9/(n-1)+1;//[)
	while(l+1<r){
		int mid=(l+r)/2;
		if(check(mid)) l=mid;
		else r=mid;
	}
	cout<<l<<endl;
	return 0;
} 
/*
3
3 5
2 6
4 1
*/

Measured memory_bytes: 13184
S = input()

ans = 0
for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        for s in S[i:j]:
            if s != "A" and s != "C" and s != "G" and s != "T":
                break
        else:
            ans = max(ans, len(S[i:j]))
print(ans)


Measured memory_bytes: 61784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    int A,B;
    cin >> A >> B;

    if (A%2 && B%2)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import queue

q = queue.Queue()
A = [[]*101 for _ in range(101)]
d = [-1]*101
visited = [False]*101

n = int(input().rstrip())
for i in range(n):
    line = [int(j) for j in input().rstrip().split()]
    A[i+1].extend(line[2:])

d[1] = 0

q.put(1)
while not q.empty():
    v = q.get()
    if visited[v] == True:
        continue
    visited[v] = True
    for i in A[v]:
        if d[i] == -1:
            d[i] = d[v] + 1
        else:
            d[i] = min(d[i],d[v] + 1)
        q.put(i)
        
for i in range(n):
    print(str(i+1)+" "+str(d[i+1]))


Measured memory_bytes: 7004
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int target = 0;
        int changedCntFrm0 = 0;
        int changedCntFrm1 = 0;

        int tile[] = new int[s.length()];

        for (int i = 0; i < s.length(); i++) {

            tile[i] = s.charAt(i);
        }


        for (int i = 0; i < s.length(); i++) {

            if (i % 2 == 0) {
                target = 48;
            } else {
                target = 49;
            }
            if (tile[i] != target) {
                changedCntFrm0++;
            }
        }

        for (int i = 0; i < s.length(); i++) {
            if (i % 2 == 0) {
                target = 49;
            } else {
                target = 48;
            }
            if (tile[i] != target) {
                changedCntFrm1++;
            }
        }
        if (changedCntFrm0 >= changedCntFrm1){
            System.out.println(changedCntFrm1);
        }else{
            System.out.println(changedCntFrm0);
        }
        sc.close();
    }
}


Measured memory_bytes: 26556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const ll MAX = 1e7 + 20;
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep1(i,n)       for(int i=1;i<=n;i++)
#define rrep(i,a,n)     for(int i=a;i<=n;i++)
#define per(i,n,a)      for(int i=n;i>=a;i--)
#define pf(n)           printf("%lld",n)
#define pfi(n)          printf("%d",n)
#define sp              printf(" ")
#define ln              "\n"

#define pi acos(-1.0)
#define mod 1000000007

///Library
#define mem(a,b) memset(a,b,sizeof(a))
#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sq(x) (x)*(x)


///vector
#define Lower_bound(vec,value) lower_bound(vec.begin(),vec.end(),value)
#define Upper_bound(vec,value) upper_bound(vec.begin(),vec.end(),value)


/*template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
*/
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast

    ll a,b;
    cin>>a>>b;
    if(a==b)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256