akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

using namespace std;

const double PI=acos(-1);

int main(){
	double a,b,h,m; cin>>a>>b>>h>>m;

	double t=abs(30*(h+m/60)-6*m)*PI/180;
	t=min(t,2*PI-t);
	printf("%.12f\n",sqrt(max(a*a+b*b-2*a*b*cos(t),0.0)));

	return 0;
}


Measured memory_bytes: 4128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    vector<int> L(n, -1), R(n, -1), pos;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'o') pos.emplace_back(i);
    }
    L[pos[0]] = 1, R[pos.back()] = k;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'x') continue;
        if(L[i] == -1)  continue;
        auto it = upper_bound(pos.begin(), pos.end(), i + c);
        if(it != pos.end()) L[*it] = min(L[i] + 1, k);
    }
    for(int i = n - 1; i >= 0; --i){
        if(s[i] == 'x') continue;
        if(R[i] == -1)  continue;
        auto it = lower_bound(pos.begin(), pos.end(), i - c);
        if(it != pos.begin())   R[*(--it)] = max(R[i] - 1, 1);
    }
    vector<int> cntL(k + 1, 0), cntR(k + 1, 0);
    for(int i = 0; i < n; ++i){
        if(s[i] == 'x') continue;
        if(L[i] != -1)  ++cntL[L[i]];
        if(R[i] != -1)  ++cntR[R[i]];
    }
    for(int i = 0; i < n; ++i){
        if(s[i] == 'x') continue;
        if(L[i] == -1 || R[i] == -1)    continue;
        if(cntL[L[i]] > 1 || cntR[R[i]] > 1)    continue;
        if(L[i] == R[i])    cout << i + 1 << '\n';
    }
}

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

int n;
int ta = 0;

int main(){
	cin >> n;
	for (int i = 1;; i++) {
		if (i*i > n) {
			break;
		}
		else {
			ta = i * i;
		}
	}
	cout << ta << endl;
}


Measured memory_bytes: 256
def main():
    from collections import Counter

    MOD = 10 ** 9 + 7

    N = int(input())
    S = input()

    ctr = Counter(S)

    ret = 1
    for count in ctr.values():
        ret = (ret * (count + 1)) % MOD
    print(ret - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import Foundation

func readInt() -> Int {
    return Int(readLine()!)!
}

func readInts(separator: String.Element = " ") -> [Int] {
    return readLine()!.split(separator: separator).map { Int($0)! }
}

func readTwoInts(separator: String.Element = " ") -> (a: Int, b: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1])
}

func mainC() {
    let (N, K) = readTwoInts()
    let terms = readInts()

    var answer: [String] = []

    for i in K...N {

        if i == K {
            // do nothing
        } else if terms[i - 1] > terms[i - 1 - K] {
            answer.append("Yes")
        } else {
            answer.append("No")
        }
    }

    answer.forEach {
        print($0)
    }
}

mainC()

Measured memory_bytes: 27244
#include "bits/stdc++.h"
using namespace std;
bool a[1002][1002];
int dp[1002][1002], mv[2][2] = {{0, 1}, {1, 0}};
int main()
{
	int h, w, mod = 1000000007;
	char n;
	scanf("%d%d", &h, &w);
	for(int i = 1; i <= h; ++i)
	{
		scanf("\n");
		for(int j = 1; j <= w; ++j)
		{
			scanf("%c", &n);
			a[i][j] = n == '.';
		}
	}
	dp[1][1] = 1;
	for(int i = 1; i <= h; ++i)
	{
		for(int j = 1; j <= w; ++j)
		{
			for(int k = 0; k < 2; ++k)
			{
				if(a[i + mv[k][0]][j + mv[k][1]])
				{
					(dp[i + mv[k][0]][j + mv[k][1]] += dp[i][j]) %= mod;
				}
			}
		}
	}
	printf("%d\n", dp[h][w]);
}

Measured memory_bytes: 5120
#include <stdio.h>
#define MAXL 100

int main(void){
    char s[MAXL+16+1];
    fgets(s, sizeof(s), stdin);
    //Atcoder X Contest
    printf("A%cC\n", s[8]);
    /*printf("str: %s\n", s);
    for(int i = 0; s[i] != '\0'; i++){
        printf("s[%d] = %c\n", i, s[i]);
    }*/
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

string YorN(bool P) { if (P)return "Yes"; else return "No"; }

int main() {

    string N;
    cin >> N;
    
    cout << YorN(N[0]==N[2]) << endl;

    return 0;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 350;
const int K = 19;
int mod =  998244353;
int dp1[N][N * N], dp2[N][N * N];
int a[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    dp1[0][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= 300 * n; j++){
            if (j >= a[i]) dp1[i][j] = (dp1[i - 1][j - a[i]] + dp1[i][j]) % mod;
            dp1[i][j] = (dp1[i][j] + 2 * dp1[i - 1][j]) % mod;
        }
    }
    dp2[0][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 0; j <= 300 * n; j++){
            if (j >= a[i]) dp2[i][j] = (dp2[i - 1][j - a[i]] + dp2[i][j]) % mod;
            dp2[i][j] = (dp2[i][j] + dp2[i - 1][j]) % mod;
        }
    }
    int s = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++) s += a[i];
    for (int i = (s + 1) / 2; i < s; i++){
        ans = (ans + 10 * mod - 3 * (dp1[n][i] - 2 * dp2[n][i])) % mod;

    }
    ans = (ans + binpow(3, n) - 3 * binpow(2, n) + 3 + 10 * mod) % mod;
    cout << ans;
}


Measured memory_bytes: 578688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 300000 + 10;
const int MOD = 998244353;

inline int inc(int a, int b) { return (a + b >= MOD) ? (a + b - MOD) : (a + b); }
inline int dec(int a, int b) { return (a >= b) ? (a - b) : (a + MOD - b); }
inline int mul(int a, int b) { return 1LL * a * b % MOD; }

inline int power(int x, int k) {
	int tmp = 1;
	while(k) {
		if(k & 1) tmp = mul(tmp,x);
		x = mul(x,x); 
		k >>= 1;
	}
	return tmp;
}

int n, a, b, fac[maxn], ifac[maxn];
ll k;

inline int C(int n, int m) {
	if(n < 0 || m < 0 || n < m) return 0;
	return mul(fac[n],mul(ifac[m],ifac[n - m]));
}

int main() {
  scanf("%d%d%d%lld", &n, &a, &b, &k);
	int Ans = 0;
	fac[0] = ifac[0] = 1;
	for(int i = 1;i <= n;i ++) fac[i] = mul(fac[i - 1],i);
	ifac[n] = power(fac[n],MOD - 2);
	for(int i = n - 1;i >= 1;i --) ifac[i] = mul(ifac[i + 1],i + 1);
	for(int z = 0;z <= n;z ++) {
    ll now = k - (ll)z * a;
		if(now % b != 0) continue;
		int y = now / b;
		if(now < 0 || y > n) continue;
		Ans = inc(Ans,mul(C(n,z),C(n,y)));
	}
	printf("%d\n", Ans);
	return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <functional>
#include <numeric>
#include "math.h"
using namespace std;

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

#define inf long long_MAX/3
#define INF long long_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<long long,long long>
#define pii pair<long long,long long>
#define pcc pair<char,char>
#define pic pair<long long,char>
#define pci pair<char,long long>
#define VS vector<string>
#define VI vector<long long>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out prlong longf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

int n;
VI a,ans;


int main(){

	cin >> n;
	a.resize(n);
	ans.resize(n);
	ll sum = 0;
	bool b = true;
	REP(i,n){
		cin >>a[i];
		if(b){
			sum +=a[i];
			b = false;
		}else{
			sum -= a[i];
			b = true;
		}

	}

	ans[0] = sum;
	FOR(i,1,n){
		ans[i] = (a[i-1]-ans[i-1]/2)*2;
	}
	REP(i,n){
		cout << ans[i] << " ";
	}

}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define all int i=0; i<n; i++
#define pb push_back
typedef long long int ll;

#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007


int main(){
	int n,a,b,c;
	cin>>n;
	vector < pair<int,int> >v[n];
	int arr[n];
	for(int i=0; i<n-1; i++){
		cin>>a>>b>>c;
		v[a-1].pb(make_pair(b-1, c));
		v[b-1].pb(make_pair(a-1, c));
	}
	deque<int>d;
	d.pb(0);
	int visit[n]={0};
	visit[0]=1;
	arr[0]=0;
	while(!d.empty()){
		int x=d.front();
		d.pop_front();
		for(int i=0; i<v[x].size(); i++){
			if(visit[v[x][i].first]==0){
				visit[v[x][i].first]=1;
				d.pb(v[x][i].first);
				if(v[x][i].second %2==0){
					arr[v[x][i].first] = arr[x];
				}
				else {
					if(arr[x]==0)arr[v[x][i].first] = 1;
					else arr[v[x][i].first] =0;
				}
			}
		}
	}
	for(int i=0; i<n; i++)cout<<arr[i]<<endl;
}


Measured memory_bytes: 7168
from collections import Counter 

N = int(input())
D = list(map(int, input().split()))

answer = 1
prev = 1
count = Counter(D)
for i in range(max(count.keys()) + 1):
    if D[0] != 0 or (i == 0 and count[i] != 1):
        answer = 0
        break
    if i not in count:
        answer = 0
        break
    answer *= prev ** count[i]
    prev = count[i]
print(answer % 998244353)

Measured memory_bytes: 62004
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

template <int MODULUS = 1000000007>
struct modulo_int {
private:

  long long value;
  constexpr void normalize() {
    value %= MODULUS;
    if (value < 0) value += MODULUS;
  }

public:

  constexpr modulo_int(const long long& value_ = 0) : value(value_) { normalize(); }
  constexpr modulo_int operator - () const { return modulo_int(MODULUS - value); }
  constexpr modulo_int operator ~ () const { return power(MODULUS - 2); }
  constexpr const long long& operator () () const { return value; }

  constexpr modulo_int operator + (const modulo_int& rhs) const { return modulo_int(*this) += rhs; }
  constexpr modulo_int& operator += (const modulo_int& rhs) {
    if ((value += rhs.value) >= MODULUS) value -= MODULUS;
    return (*this);
  }

  constexpr modulo_int operator - (const modulo_int& rhs) const { return modulo_int(*this) -= rhs; }
  constexpr modulo_int& operator -= (const modulo_int& rhs) {
    if ((value += MODULUS - rhs.value) >= MODULUS) value -= MODULUS;
    return (*this);
  }

  constexpr modulo_int operator * (const modulo_int& rhs) const { return modulo_int(*this) *= rhs; }
  constexpr modulo_int& operator *= (const modulo_int& rhs) {
    (value *= rhs.value) %= MODULUS;
    return (*this);
  }

  constexpr modulo_int operator / (const modulo_int& rhs) const { return modulo_int(*this) /= rhs; }
  constexpr modulo_int& operator /= (const modulo_int& rhs) {
    return (*this) *= ~rhs;
  }

  constexpr modulo_int power (const long long& pow) const {
    modulo_int result(1), mult(*this);
    for (long long t = pow; t > 0; t >>= 1) {
      if (t & 1) result *= mult;
      mult *= mult;
    }
    return result;
  }

  friend std::istream& operator >> (std::istream& stream, modulo_int& lhs) {
    stream >> lhs.value;
    lhs.normalize();
    return stream;
  }

  friend std::ostream& operator << (std::ostream& stream, const modulo_int& rhs) {
    return stream << rhs.value;
  }

};

constexpr int mod = 998244353;
using modint = modulo_int<mod>;

int N;
int R[2001], B[2001];
std::string S;
modint dp[4001][4001];

int main() {

  std::cin >> S;
  N = S.size();

  rep (i, N) {
    int r = S[i] - '0';
    int b = 2 - r;
    R[i + 1] += R[i] + r;
    B[i + 1] += B[i] + b;
  }

  dp[0][0] = 1;
  rep (i, 2 * N) {
    int nowr = R[std::min(i + 1, N)];
    int nowb = B[std::min(i + 1, N)];
    rep (r, 0, nowr) {
      int b = i - r;
      if (nowr >= r + 1) {
        dp[i + 1][r + 1] += dp[i][r];
      }
      if (nowb >= b + 1) {
        dp[i + 1][r] += dp[i][r];
      }
    }
  }

  std::cout << dp[N * 2][R[N]] << '\n';
  return 0;

}


Measured memory_bytes: 123520
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e3+2;
const int maxx=maxn*maxn;
const int q=1e9+7;
inline int Plus(int x,int y) {return (x+=y)>=q?x-q:x;}
inline void Pe(int &x,int y) {x=Plus(x,y);}
inline int Multi(int x,int y) {return 1ll*x*y%q;}
inline void Me(int &x,int y) {x=Multi(x,y);}
namespace num {
	int fac[maxx],ifac[maxx],inv[maxx];
	inline int C(int n,int m) {return n<m?0:Multi(Multi(fac[n],ifac[m]),ifac[n-m]);}
	void init() {
		fac[0]=fac[1]=ifac[0]=ifac[1]=inv[0]=inv[1]=1;
		for (int i=2;i<maxx;++i) {
			inv[i]=Multi(q-q/i,inv[q%i]);
			fac[i]=Multi(fac[i-1],i);
			ifac[i]=Multi(ifac[i-1],inv[i]);
		}
	}
}
int n,k,f[maxn];
int main() {
	num::init();
	cin>>n>>k;
	if (k==1) puts("1"),exit(0);
	f[0]=1;
	for (int i=1;i<=n;++i,f[0]=f[1]) {
		for (int j=i;j;--j) {
			int tmp=num::C((i-1)*k-(j-1)+k-2,k-2);
			f[j]=Plus(Multi(Multi(n-i+1,f[j-1]),tmp),f[j+1]);
		}
	}
	printf("%d\n",f[0]);
	return 0;
}


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

int main() {
  string S;
  cin >> S;
  int L, R;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'A') {
      L = i;
      break;
    }
  }
  for (int i = S.size()-1; i > 0; i--) {
    if (S[i] == 'Z') {
      R = i;
      break;
    }
  }
  
  cout << R-L+1 << endl;
}

Measured memory_bytes: 640
<?php
$string = trim(fgets(STDIN));
$length = strlen($string);
$string2 = substr($string, 0, ($length - 1) / 2);
$string3 = substr($string, ($length + 3) / 2 - 1, $length);

if ($string === strrev($string)
    && $string2 === strrev($string2)
    && $string3 === strrev($string3)) {
    echo 'Yes';
} else {
    echo 'No';
}


Measured memory_bytes: 4984
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int n,m;
  cin>>n>>m;
  using P = pair<Int, Int>;
  vector<vector<P> > G(n);
  for(Int i=0;i<n-1;i++){
    Int u,v,c;
    cin>>u>>v>>c;
    u--;v--;
    G[u].emplace_back(v,c);
    G[v].emplace_back(u,c);
  }
  vector<Int> w(n);
  for(Int i=0;i<n;i++) cin>>w[i];
  priority_queue<Int> pq;
  vector<Int> dp(n);
  function<void(Int, Int, Int)> dfs=[&](Int r,Int v,Int p){
    for(auto e:G[v]){
      Int u=e.first;
      if(u==p) continue;
      dfs(r,u,v); 
    }
    Int idx=-1;
    for(auto e:G[v]){
      Int u=e.first,c=e.second;
      if(u==p) continue;
      if(idx<0||dp[u]+c>dp[v])
	idx=u,dp[v]=dp[u]+c;
    }
    if(idx<0){
      dp[v]=0;
      return;
    }
    for(auto e:G[v]){
      Int u=e.first,c=e.second;
      if(u==p) continue;
      if(u==idx) continue;
      pq.emplace((dp[u]+c)*w[r]);
    }
    if(v==r) pq.emplace(dp[v]*w[r]);
  };
   
  for(Int i=0;i<n;i++) dfs(i,i,-1);
   
  Int ans=0;
  while(m&&!pq.empty()){
    ans+=pq.top();pq.pop();
    m--;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 36084
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

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

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RREP(i, n) for(int i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(int i = 0; i < n; i += k)


int main()
{
	int n;
	cin >> n;

	vector<int> t(n);
	vector<double> v(n), spd(40005, 1e9);
	REP(i, n) {
		cin >> t[i];
	}
	REP(i, n) {
		cin >> v[i];
	}

	int s = 0;
	REP(i, n) {
		t[i] *= 2;
		for (int j = s; j <= s + t[i]; j++) {
			spd[j] = min(spd[j], v[i]);
		}
		s += t[i];
	}

	spd[0] = 0;
	spd[s] = 0;
	REP(i, s) {
		spd[i + 1] = min(spd[i + 1], spd[i] + 0.5);
	}
	for (int i = s - 1; i >= 0; i--) {
		spd[i] = min(spd[i], spd[i + 1] + 0.5);
	}

	double ans = 0;
	REP(i, s) {
		ans += spd[i] + spd[i + 1];
	}

	printf("%.5lf\n", ans / 4.0);
}

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

int main(){
    int num;
    std::vector<int> v;
    std::cin >> num;

    for(int i = 0; i < num; ++i){
        int val;
        std::cin >> val;
        v.push_back(val);
    }

    int swapCount = 0;
    for(int i = 0; i < num; ++i){
        for(int j = num -1; j > i; --j){
            if(v[j] < v[j - 1]){
                int tmp = v[j];
                v[j] = v[j - 1];
                v[j - 1] = tmp;
                ++swapCount;
            }
        }
    }

    std::cout << v[0];
    for(int i = 1; i < num; ++i){
        std::cout << ' ' << v[i];
    }
    std::cout << std::endl;
    std::cout << swapCount << std::endl;

    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main () {
  unsigned long long int n, a, b;
  cin >> n >> a >> b;
  unsigned long long int sum=0;
  sum = n/(a+b)*a;
  n = n % (a+b);
  if (n < a){
    sum = sum + n;
  } else{
    sum = sum + a;
  }
  
  cout << sum;
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vst s(n);
  vin(s);
  ll m;
  cin >> m;
  vst t(m);
  vin(t);

  map<st, ll> money;
  vrep(i, s){
    if(money.count(i)) money[i]++;
    else money[i] = 1;
  }
  vrep(i, t) if(money.count(i)) money[i]--;
  ll ans = 0;
  for(auto& i : money) if(i.second > ans) ans = i.second;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
const ll N = 2e3+5;
ll n;
vector< pll > a;
ll dp[N][N];
ll compute(ll l, ll r)
{
    ll i = n - (r-l+1);
    if(dp[l][r] != -1) return dp[l][r];
    if(l == r)
    {
        ll val = a[i].ff*llabs(a[i].ss - l);
        return dp[l][r] = val;
    }
    ll ans = 0;
    // keep left
    ll val = a[i].ff*llabs(a[i].ss - l) + compute(l+1, r);
    ans = MAX2(ans, val);

    // keep right
    val = a[i].ff*llabs(a[i].ss - r) + compute(l, r-1);
    ans = MAX2(ans, val);

    return dp[l][r] = ans;
}
int main()
{
    she_told_me_dont_worry
    ll i, j;
    cin>>n;
    FOR0(i, n)
    {
        pll temp = pll(0, i);
        cin>>temp.ff;
        a.pb(temp);
    }
    sort(a.begin(), a.end(), greater< pll >());
    FOR0(i, n+5) FOR0(j, n+5) dp[i][j] = -1;
    ll ans = compute(0, n-1);
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 35396
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<ll> a(2 * n), s(2 * n + 1, 0);

    REP(i, n) {
        cin >> a[i];
        a[i + n] = a[i];
    }

    REP(i, 2 * n) {
        s[i + 1] = s[i] + a[i];
    }
    
    auto check = [&](ll x) {
        REP(i, n) {
            int j = lower_bound(s.begin() + i, s.end(), s[i] + x) - s.begin();
            int k = lower_bound(s.begin() + j, s.end(), s[j] + x) - s.begin();

            if (j < n + i && k < n + i && s[n + i] - s[k] >= x) {
                return true;
            }
        }

        return false;
    };

    ll l = 0, r = 1e15;
    while (r - l > 1) {
        ll m = (r + l) / 2;

        if (check(m)) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << l << endl;

    return 0;
}



Measured memory_bytes: 5968
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
    cin >> N;
    for(int i = 0; i <= 50000; i++) {
        if(int(1.08 * i) == N) {
            cout << i;
            return 0;
        }
    }
    cout << ":(";
}

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int ans = 0;
//????????°,n-?????¨???????¨?,?????¨???????????????
void solve(int plus,int nowsum, int kaisu){
	if(kaisu == 0){
		if(nowsum == 0) ans++;
		return;
	}
	if(plus == 10) return;
	//plus???????????¨???
	solve(plus+1, nowsum - plus, kaisu-1);
	//plus?????????????????£?????¨???
	solve(plus+1, nowsum, kaisu);
}
int main(){
	int n,s;
	while(1){
		ans = 0;
		cin >> n >> s;
		if(n == 0 && s == 0) break;
		solve(0,s,n);
		cout << ans << endl;
	}	
}

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

using namespace std;

int main()
{
 int a,b,c;
  cin>>a>>b>>c;
  if(b==a)
  {
   cout<<c<<endl;
    return 0;
  }
  if(b+c<=a)
  {
    cout<<0<<endl;
    return 0;
  }
  cout<<abs(c-(a-b))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
inline long long	read()//不管是正负数，都可以 
{
	long long x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(long long a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(long long a){
	write(a); puts("");
}
const long long N=100005;
long long n,a[N],b[N],A,B,l,r;
inline bool check(long long x){
	long long sum=0;
	for(long long i=1;i<=n;i++)if((long long)a[i]<(long long)x*B)b[i]=0; else b[i]=a[i]-x*B;
	for(long long i=1;i<=n;i++)if(b[i]>0){sum+=(b[i]+A-1)/A; if(sum>x)return 0;}
	return 1;
}
int main(){
	n=read(); A=read(); B=read(); A-=B;
	for(long long i=1;i<=n;i++){a[i]=read(); }
	l=1; r=2000000001/B;
	while(l<r){
		long long mid=(l+r)>>1;
		if(check(mid))r=mid; else l=mid+1;
	}
	writeln(l);
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void)
{
    int N,dice1,dice2;
    int counter=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        scanf("%d %d",&dice1,&dice2);
        if(dice1==dice2)
            counter++;
        else
            counter=0;
        if(counter==3)
        {
            printf("Yes\n");
            break;
        }
        else if(i==N-1)
        {
            printf("No\n");
        }   
    }
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<fstream>
using namespace std;
int main() {
	int D = 0;
	
	int most = 0;
	int count = 0;
	int sum = 0;
	std::cin >> D;
	int *p = new int[D];
	for (int i = 0; i < D; i++) {
		cin >> p[i];
	}
	if (2 > D || 10 < D) {
		std::cout << "error" <<std::endl;
	}
	else {
		for (int i = 0; i < D; i++) {
			if (p[i] > most) {
				most = p[i];
				count = i;
			}
		}
	}

	for (int i = 0; i < D; i++) {
		if (i == count) {
			sum += p[i] / 2;
			//cout << i << endl;
		}
		else {
			sum += p[i];
			
		}
	}

	cout << sum << endl;

	////std::cout << D << std::endl;
	//if (D == 25) {
	//	std::cout << "Christmas" << std::endl;
	//}
	//else if (D == 24) {
	//	std::cout << "Christmas Eve" << std::endl;
	//}
	//else if (D == 23) {
	//	std::cout << "Christmas Eve Eve" << std::endl;
	//}
	//else if (D == 22) {
	//	std::cout << "Christmas Eve Eve Eve" << std::endl;
	//}
	//else {
	//	std::cout << "error" << std::endl;
	//}
}



Measured memory_bytes: 256
#a以上のbの倍数の最小値
def baisu(a,b):
  if a%b==0:
    return a
  else:
    return ((a//b)+1)*b
C=list()
S=list()
F=list()
N=int(input())
for i in range(N-1):
  c,s,f=map(int,input().split())
  C.append(c)
  S.append(s)
  F.append(f)
L = [[0 for j in range(N)] for i in range(N)]
for i in range(N-1):
  L[i][i]=S[i]
  for j in range(i+1,N):
    L[i][j]=baisu(max(L[i][j-1],S[j-1]),F[j-1])+C[j-1]
  print(L[i][-1])
print(0)

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

int main() {
  std::string s;
  std::cin >> s;

  bool flag = true;

  if (s[0] != 'A') {
    flag = false;
  }

  int count = 0;
  for (int i = 2; i <= s.size() - 2; i++) {
    if (s[i] == 'C') {
      count++;
    }
  }

  if (count != 1) {
    flag = false;
  }

  for (int i = 1; i < s.size(); i++) {
    if (s[i] != 'C' && s[i] != tolower(s[i])) {
      flag = false;
    }
  }

  if (flag) {
    std::cout << "AC" << std::endl;
  } else {
    std::cout << "WA" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-4;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;

int n;
vector<ld> calc(ld a, ld b, ld c) {
	if (abs(a)<eps)return { -c / b };
	ld z = b * b - 4 * a*c;
	if (z < 0)return {};
	ld dz = sqrt(z);
	return{ (-b + dz) / (ld)(2 * a),(-b - dz) / (ld)(2 * a) };
}
void solve() {
	vector<vector<ld>> c(n),v(n);
	vector<ld> r(n), vr(n);
	rep(i, n) {
		c[i].resize(3), v[i].resize(3);
		rep(j, 3)cin >> c[i][j];
		rep(j, 3)cin >> v[i][j];
		cin >> r[i] >> vr[i];
	}
	vector<bool> used(n, false);
	vector<ld> ans(n);
	rep(aa, n) {
		ld mi = INF; int chk1=-1, chk2=-1;
		rep(i, n)if (!used[i]) {
			Rep(j,i+1, n)if (!used[j]) {
				ld a[3] = {};
				rep(k, 3) {
					ld dv = v[i][k] - v[j][k];
					ld dc = c[i][k] - c[j][k];
					a[0] += dv * dv;
					a[1] += 2 * dv*dc;
					a[2] += dc * dc;
				}
				ld dr = r[i] + r[j];
				ld vdr = vr[i] + vr[j];
				a[0] -= vdr * vdr;
				a[1] += 2 * dr*vdr;
				a[2] -= dr * dr;
				vector<ld> cc = calc(a[0], a[1], a[2]);
				rep(k, cc.size()) {
					if (cc[k] < 0)continue;
					if (cc[k] > r[j] / vr[j])continue;
					if (cc[k] < mi) {
						mi = cc[k]; chk1 = i, chk2 = j;
					}
				}
			}
		}
		bool upd = false;
		rep(i, n)if(!used[i]) {
			if (r[i] / vr[i] < mi) {
				mi = r[i] / vr[i]; chk1 = i; upd = true;
			}
		}
		if (chk1 < 0)break;
		if (upd) {
			ans[chk1] = mi; used[chk1] = true;
		}
		else {
			ans[chk1] = ans[chk2] = mi; used[chk1] = used[chk2] = true;
		}
	}
	rep(i, n) {
		//cout << "ans is ";
		cout << ans[i] << endl;
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(10);
	while (cin >> n,n)solve();
	//solve();
	//stop
	return 0;
}



Measured memory_bytes: 3340
use proconio::{fastout, input, marker::Chars};
#[allow(unused_mut)]
#[fastout]
fn main() {
    input! {
        n: usize,
        s: Chars
    }
    let mut res = if n % 2 == 0 { true } else { false };
    if s[..s.len() / 2] != s[s.len() / 2..] {
        res = false;
    }
    println!("{}", if res { "Yes" } else { "No" });
}


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

int main(){

    string s; cin >> s;
    string t; cin >> t;
    int n = (int)s.size();
    int m = (int)t.size();

    bool dame = false;

    for(int i = n - m; i >= 0; i--){
        
        bool flag = true;
        for(int j = 0; j < m; j++){
            if(s[j + i] != '?' && t[j] != s[j + i]){
                flag = false;
                break;
            }
        }

        if(flag){
            dame = true;
            for(int j = 0; j < m; j++) s[j + i] = t[j];
            break;
        }
    } 

    if(!dame){
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for(int i = 0; i < n; i++){
        if(s[i] == '?') s[i] = 'a';
    }

    cout << s << endl;
    return 0;
}

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

//  c0 c1 c2 c3 c4 c5 c6
//  a0 a1 a2 a3 a4 a5 a6
const int tam = 1e5+10;
long long dp[tam];
long long h[tam];
int k;
long long INF = 1e18;


int solve( int i  ) {
    if( i <= 1 ) return abs(h[0]-h[i]);
    long long &ans = dp[i];
    if( ans != -1 ) return ans;
    ans = INF;
    for( int j = 1; j <= k; j++ ) {
        if( i-j >= 0 )
            ans = min( ans, solve(i-j) + abs(h[i-j]-h[i]) );
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n;
    cin >> n >> k;
    for( int i = 0; i < n; i++  ) {
        cin >> h[i];
    } 
    // dp[0] = 0;
    // for( int i = 1; i < n; i++ ) {
    //     dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
    //     for( int j = 2; j <= k; j++)
    //     if( j <= i ) {
    //         dp[i] = min( dp[i], dp[i-j] + abs(h[i]-h[i-j]) );
    //     }
    // }
    // cout << dp[n-1] << '\n';
    memset( dp, -1, sizeof dp );
    cout << solve(n-1) << '\n';
    return 0;
}

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

#define Bye return 0
#define ll long long
const ll MAX = 1e2;

void solve(){
    string a, b; cin>>a>>b;

    char str[MAX];
    for (int i=0, j=0; i<max(a.size(), b.size()); i++, j+=2){
        str[j] = (i<a.size() ? a[i] : ' ');
        str[j+1] = (i<b.size()) ? b[i] : ' ';
    }

    for (int i=0; i<a.size()+b.size(); i++){
        if(str[i] == ' ') continue;
        printf("%c", str[i]);
    } printf("\n");
}

int main(){
    solve();
    Bye;
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>

int main(void)
{
	int table[8] = {1, 4, 1, 2, 1, 2, 1, 4};
	int user[8];

	while (~scanf("%d", user)){
		int i, offset, minv, maxu;

		for (i = 1; i < 8; i++){
			scanf("%d", user + i);
		}
		
		minv = 9e8;
		maxu = offset = 0;
		for (i = 0; i < 8; i++){
			int j, v, u;
			u = v = 0;
			for (j = 0; j < 8; j++){
				int t = table[(j + i) % 8];
				v = v * 10 + t;
				u += fmin(t, user[j]);
			}
			if (maxu < u){
				offset = i;
				maxu = u;
				minv = v;
			} 
			else if (maxu == u){
				if (minv > v){
					offset = i;
					minv = v;
				}
			}
		}
		for (i = 0; i < 8; i++){
			printf("%d%c", table[(i + offset) % 8], i == 7 ? '\n' : ' ');
		}
	}
	return (0);
}

Measured memory_bytes: 604
#include <iostream>
#include <unordered_set>
#include <cstdint>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;

	for (int i = 0; i < k; i++)
	{
		if (a <= b && b >= c)
			c *= 2;
		else if (a >= b)
			b *= 2;
		else if (a >= c)
			c *= 2;
		else if (a <= b && b >= c)
			c *= 2;
		if (a < b && b < c)
		{
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 3620
main(){
  int a[6],i,j;
  while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=-1){
    for(i=0;i<5-1;i++)
      for(j=i+1;j<5;j++)
	if(a[i]>a[j]){
	  a[5]=a[i];
	  a[i]=a[j];
	  a[j]=a[5];
	}
    if((a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3])||(a[1]==a[2]&&a[2]==a[3]&&a[3]==a[4]))
      puts("four card");
    else if((a[0]==a[1]&&a[1]==a[2]&&a[3]==a[4])||(a[0]==a[1]&&a[2]==a[3]&&a[3]==a[4]))
      puts("full house");
    else if((a[1]==a[0]+1&&a[2]==a[1]+1&&a[3]==a[2]+1&&a[4]==a[3]+1)||(a[0]==1&&a[1]==10&&a[2]==11&&a[3]==12&&a[4]==13))
      puts("straight");
    else if((a[0]==a[1]&&a[1]==a[2])||(a[1]==a[2]&&a[2]==a[3])||(a[2]==a[3]&&a[3]==a[4]))
      puts("three card");
    else if((a[0]==a[1]&&a[2]==a[3])||(a[0]==a[1]&&a[3]==a[4])||(a[1]==a[2]&&a[3]==a[4]))
      puts("two pair");
    else if(a[0]==a[1]||a[1]==a[2]||a[2]==a[3]||a[3]==a[4])
      puts("one pair");
    else
      puts("null");
  }
  return 0;
}

Measured memory_bytes: 0
import sys
def main():
    input = sys.stdin.readline
    N = int(input())
    E = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        E[a].append((b,i))
        E[b].append((a,i))
    
    def dfs(s, g):
        par = [(-1,-1)] * N
        par[s] = (s,-1)
        stack = [s]
        while stack:
            v = stack.pop()
            for to, i in E[v]:
                if par[to][0] >= 0: continue
                par[to] = (v, i)
                if to == g: break
                stack.append(to)
        r = 0
        v = g
        while v != s:
            v, i = par[v]
            r |= 1 << i
        return r
    
    M = int(input())
    path = [0] * M
    for i in range(M):
        u, v = map(int, input().split())
        u, v = u-1, v-1
        path[i] = dfs(u, v)

    def calc(s): return 1<<(N-1-popcount(s))

    i_ans = 0
    for p in range(1, 1<<M):
        is_odd = 0
        s = 0
        for i in range(M):
            if p&1:
                s |= path[i]
                is_odd ^= 1
            p >>= 1
        if is_odd: i_ans += calc(s)
        else: i_ans -= calc(s)

    print((1<<(N-1)) - i_ans)

def popcount(x):
    x = (x & 0x5555555555555555) + (x >> 1 & 0x5555555555555555);
    x = (x & 0x3333333333333333) + (x >> 2 & 0x3333333333333333);
    x = (x & 0x0f0f0f0f0f0f0f0f) + (x >> 4 & 0x0f0f0f0f0f0f0f0f);
    x = (x & 0x00ff00ff00ff00ff) + (x >> 8 & 0x00ff00ff00ff00ff);
    x = (x & 0x0000ffff0000ffff) + (x >>16 & 0x0000ffff0000ffff);
    return (x & 0x00000000ffffffff) + (x >>32 & 0x00000000ffffffff);

if __name__ == '__main__':
    main()

Measured memory_bytes: 42732
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define fl '\n'
#define vi vector<int>
#define sz size
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);

    string s;
    vi v;
    cin>>s;
    for(int i=0;i<s.sz();i++){
        if(s[i]=='0')v.pb(0);
        if(s[i]=='1')v.pb(1);
        if(s[i]=='B' && v.sz())v.pop_back();
    }
    for(auto it:v)cout<<it;

    return 0;
}


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

using namespace std;

void A_AC_or_WA(void) {

	int N, M;
	cin >> N >> M;
	cout << ((N == M) ? "Yes" : "No") << flush;
}

void B_Comparing_Strings(void) {

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

	for (int loop = 0; loop < max(a, b); loop++) cout << min(a, b);
	cout << flush;
	return;
}

int main(void) {

	//A_AC_or_WA();
	B_Comparing_Strings();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
using namespace std;
const int MOD =998244353;
const int N = 300003;
ll fact[N], inv[N];

ll bin(ll n, ll m){
    if(m==1) return n;
    
    if(m%2==0){
        n = (n*n)%MOD;
        return bin(n,m/2)%MOD;
    }
    return (n* bin((n*n)%MOD,m/2))%MOD;
}

void fun(){
    fact[0] =1;
    for(int i=1;i<N;i++){
        fact[i] = (i*fact[i-1])%MOD;
        inv[i] = bin(fact[i],MOD-2);
    }
    inv[0] = 1;
}

ll ncr(int n,int r){
    return ((fact[n]*inv[r])%MOD*inv[n-r])%MOD;
}

int main() {
    ll ans =0;
    ll n,a,b,k;
    fun();
    cin>>n>>a>>b>>k;
    for(int i=0;i<=n;i++){
        if( (k-(a*i))%b!=0) continue;
        int j =  (k-(a*i))/b;
        if(j<0 || j>n) continue;
        ans+=(ncr(n,i)*ncr(n,j))%MOD;
        ans%=MOD;
    }
    cout<<ans;
}


Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
int main() {
	char str[128] = "";
	//FILE *fp;
	int cnt = 0, i, j, flg;
	//fp=fopen("input.txt", "r");
	while (~fscanf(stdin, "%s", str)) {
		i = 0, j = strlen(str) - 1, flg = 1;
		while (j > i) {
			if (str[i] != str[j]) { flg = 0; break; }
			++i, --j;
		}
		if (flg) cnt++;
	}
	//fclose(fp);
	fprintf(stdout, "%d\n", cnt);
	return 0;
}

Measured memory_bytes: 544
n,m,v,p=map(int,input().split())
A=sorted(list(map(int,input().split())))[-p::-1]
s=0;p-=1
for u,a in enumerate(A):
 if a<A[0]-m or u*a+m*n-m*v<s:break
 s+=a;p+=1
print(p)

Measured memory_bytes: 62576
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

const int MOD = 1e9 + 7;

int add(int x, int y) {
    x += y;
    if (x >= MOD)
        return x - MOD;
    return x;
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <vector <int>> ones(1 << n);
    forn (mask, 0, 1 << n)
        forn (j, 0, n)
            if ((mask >> j) & 1)
                ones[mask].pb(j);
    vector <int> dp(1 << n);
    dp[0] = 1;
    forn (i, 0, n) {
        vector <int> good(n);
        cin >> good;
        vector <int> new_dp(1 << n);
        forn (mask, 0, 1 << n) {
            long long t = 0;
            for (int j : ones[mask]) {
                if (good[j])
                    t += dp[mask ^ (1 << j)];
            }
            new_dp[mask] = t % MOD;
        }
        swap(dp, new_dp);
    }
    cout << dp[(1 << n) - 1];
    return 0;
}

Measured memory_bytes: 219512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
using namespace __gnu_pbds;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n; cin >> n;
	vector<ll>v(n);
	int pos = 0, neg = 0;
	ll sum = 0, mn = mod, mx = -mod;
	for(int i = 0; i < n; i++)
	{
		cin >> v[i];
		sum += abs(v[i]);
		if(v[i] >= 0)
		{
			++pos;
			mn = min(mn, v[i]);
		}
		if(v[i] <= 0)
		{
			++neg;
			mx = max(mx, v[i]);
		}
	}
	sort(all(v));
	if(pos > 0 && neg > 0)
	{
		cout << sum << "\n";
		int la = 0;
		for(int i = 0; i < n; i++)
			if(v[i] < 0) la = i;
		for(int i = la + 1; i < n - 1; i++)
		{
			cout << v[0] << " " << v[i] << "\n";
			v[0] -= v[i];
		}
		for(int i = 0; i <= la; i++)
		{
			cout << v[n - 1] << " " << v[i] << "\n";
			v[n - 1] -= v[i];
		}
	}
	else
	{
		if(pos == n)
		{
			cout << sum - mn * 2 << "\n";
			if(n == 2)
				cout << v[1] << " " << v[0] << "\n";
			else
			{
				for(int i = 2; i < n; i++)
				{
					cout << v[0] << " " << v[i] << "\n";
					v[0] -= v[i];
				}
				cout << v[1] << " " << v[0] << "\n";
			}
		}
		else
		{
			cout << sum + mx * 2 << "\n";
			for(int i = 0; i < n - 1; i++)
			{
				cout << v[n - 1] << " " << v[i] << "\n";
				v[n - 1] -= v[i];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a,b,c=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        string s=to_string(i);
        if(s[0]==s[4]&&s[1]==s[3])c++;
    }
    cout<<c;
}


Measured memory_bytes: 256
/*input
7
1 2 3 4 5 6
*/
/*

**************************
*						 *
* AUTHOR :: knight_coder *
*						 *
**************************

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rrep(i,m,n)	for(lld i=m;i>=n;i--)
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; 
//change null_type to get ordered_map
#define N  100005
#define DEC(N)	cout << std::fixed; cout << setprecision(N);
void solve()
{
	lld n;
	cin >> n;
	lld cnt[n+2]; 
	rep(i,0,n+2){
		cnt[i]=0;
	}
	rep(i,2,n+1){
		lld x;
		cin >> x;
		cnt[x]++;
	}
	rep(i,1,n+1){
		cout << cnt[i] << endl;
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

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

using namespace std;

#define int long long

signed main(){
	int n, a, b; 
	cin>>n>>a>>b;
	if(a > b) swap(a, b);
	if((b-a)%2 == 0){
		cout<<(b-a)/2<<endl;
		return 0;
	}
	
	//left guys goes to 0 and comes back
	int left = (a - 1) + 1 + (b - (a - 1 + 1) - 1)/2;
	int right = n - b + 1 + (n - (a + (n - b + 1)))/2;
	int ans = min(left, right);
	cout<<ans<<endl;
}

Measured memory_bytes: 256