akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	string s, t;
	cin >> s >> t;
	lli n = t.size();
	t.erase(n-1, 1);
	if(s == t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3624
import itertools
import os
import sys

import numpy as np

# from libs.debug import debug

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, K = list(map(int, sys.stdin.buffer.readline().split()))
A = list(map(int, sys.stdin.buffer.readline().split()))

A = np.array(A, dtype=int)
minuses = np.msort(np.abs(A[A < 0]))
pluses = np.msort(A[A > 0])
zeros = A[A == 0]


def solve():
    p = []
    for a, b in itertools.combinations(A, r=2):
        p.append(a * b)
    p.sort()
    print(p[K - 1])


def test(n):
    # n 以下の数が k こ以上ある
    minus_cnt = len(minuses) * len(pluses)
    zeros_cnt = len(zeros) * (N - len(zeros)) + (len(zeros) * (len(zeros) - 1) // 2)
    if n == 0:
        return minus_cnt + zeros_cnt >= K
    ret = minus_cnt + zeros_cnt
    if n > 0:
        a = np.searchsorted(pluses, n // pluses, side='right')
        b = np.searchsorted(minuses, n // minuses, side='right')
        c = pluses ** 2 <= n
        d = minuses ** 2 <= n
        return ret + (a.sum() + b.sum() - c.sum() - d.sum()) // 2 >= K
    else:
        a = np.searchsorted(-minuses[::-1], n // pluses, side='right')
        b = np.searchsorted(-pluses[::-1], n // minuses, side='right')
        return (a.sum() + b.sum()) // 2 >= K


ok = 10 ** 18 - 1
ng = -10 ** 18 - 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if test(mid):
        ok = mid
    else:
        ng = mid
print(ok)

# solve()


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

int main(){
  int N;
  cin>>N;
  vector<int>H(N);
  for(int i=0;i<N;i++)
    cin>>H.at(i);
  int res=1;
  int maxH=H.at(0);
  
  for(int i=1;i<N;i++){
    if(H.at(i)>=maxH){
      res++;
      maxH=H.at(i);
    }
  }
  cout<<res;
}



Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
sdictlist = []
sdictlistsorted = []
for i in range(D):
  onedict = {}
  for j in range(26):
    onedict[j] = s[i][j]
  sdictlist.append(onedict)
  onesorteddict = sorted(onedict.items(), key=lambda x:x[1], reverse=True)
  sdictlistsorted.append(onesorteddict)
  
#for i in range(D):
#  print(sdictlistsorted[i][0][0]+1)

num = 1
for i in range(D):
  print(num)
  if(num == 26):
    num = 1
  elif(num == 25):
    num = 2
  else:
    num += 2

Measured memory_bytes: 10564
import java.util.Scanner;

public class Main {
 private static final Integer END_FLAG = Integer.valueOf(0);
 static Scanner               in       = new Scanner(
	                                       System.in);
 static Integer               nextValue;

 public static void main(String[] args) {
	int caseNum = 0;
	do {
	 int n = (nextValue != null) ? nextValue : in.nextInt();
	 printCase(++caseNum);
	 int[][] jpeg = new int[n][n];
	 int x = 0;
	 final int lastX = n * n;
	 final int lastIndex = n - 1;
	 int column = 0, row = 0;
	 int nextStartColumn = 0, nextStartRow = 0, d = 1;
	 while (x < lastX) {
		column = nextStartColumn;
		row = nextStartRow;
		while (0 <= column && column < n && 0 <= row && row < n) {
		 jpeg[column][row] = ++x;
		 nextStartColumn = column;
		 nextStartRow = row;
		 column -= d;
		 row += d;
		}
		if (nextStartColumn == lastIndex || (nextStartColumn == 0 && nextStartRow != lastIndex)) {
		 nextStartRow++;
		} else if (nextStartRow == lastIndex || (nextStartRow == 0 && nextStartColumn != lastIndex)) {
		 nextStartColumn++;
		}

		d = -d;
	 }
	 for (column = 0; column < n; column++) {
		for (row = 0; row < n; row++) {
		 System.out.printf("%3d",jpeg[column][row]);
		 if (row == lastIndex) {
			System.out.println();
		 }
		}
	 }
	 nextValue = Integer.valueOf(in.next());
	} while (!nextValue.equals(END_FLAG));
 }

 private static void printCase(int caseNum) {
	System.out.print("Case ");
	System.out.print(caseNum);
	System.out.println(':');
 }
}

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

int main() {
  
  string s; cin >> s;
  
  vector<char> vec(0);
  
  for (int i = 0; i < s.size(); i++) {
    
    char tmp = s.at(i);
    
    if (tmp == '0') vec.push_back('0');
    
    if (tmp == '1') vec.push_back('1');
    
    if (tmp == 'B') {
      if (vec.size() == 0) continue;
      vec.pop_back();
    }
    
  }
  
  for (auto x : vec) cout << x;
  
  cout << endl;
  
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>

using namespace std;

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

int main() {
  int n;
  cin >> n;
  rep (iii, n) {
    int a[3];
    rep (i, 3) cin >> a[i];
    sort(a, a + 3);
    if (a[0] * a[0] + a[1] * a[1] == a[2] * a[2]) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())

bool solve() {
    ll n;
    cin >> n;
    
    ll sum = 0;
    vector<ll> a(n);
    for (auto& ai : a) { cin >> ai; sum += ai; }
    ll tmp = n * (n + 1) / 2;
    ll k = sum / tmp;
    if (sum % tmp != 0) return 0;
    
    vector<ll> b(n);
    rep(i, n) { b[i] = a[(i + 1) % n] - a[i]; b[i] -= k; }
    // outa(b, n);
    
    bool ret = 1;
    rep(i, n) {
        ret &= (b[i] <= 0LL && b[i] % n == 0LL);
    }
    // outa(b, n);
    
    if (ret) return 1;
    return 0;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    if (solve()) out("YES");
    else out("NO");
}



Measured memory_bytes: 1792
//42
#include<iostream>
#include<utility>
#include<cctype>
#include<cstdio>

using namespace std;

char s[101];
bool f;
int i;
typedef pair<int,int> pii;

void co(pii a){
  f|=a.first<-10000||10000<a.first||a.second<-10000||10000<a.second;
}

pii pp();
pii pm();
pii pn();

pii pn(){
  if(s[i]=='i'){
    i++;
    return make_pair(0,1);
  }else if(isdigit(s[i])){
    int d,n;
    d=0;
    while(isdigit(s[i])){
      d=(d*10+s[i]-'0');
      co(pii(d,0));
      i++;
    }
    //    sscanf(s+i,"%d%n",&d,&n);
    //    i+=n;
    pii r=pii(d,0);
    co(r);
    return r;
  }else if(s[i]=='('){
    i++;
    pii r=pp();
    i++;
    return r;
  }else{
    return pii();
  }
}

pii pm(){
  pii a=pn();
  while(s[i]=='*'){
    i++;
    pii b=pn();
    pii c=pii(a.first*b.first-a.second*b.second,a.first*b.second+a.second*b.first);
    a=c;
    co(a);
  }
  return a;
}

pii pp(){
  pii a=pm();
  while(s[i]=='+'||s[i]=='-'){
    char o=s[i];
    i++;
    pii b=pm();
    a.first+=b.first*((o=='+')?1:-1);
    a.second+=b.second*((o=='+')?1:-1);
    co(a);
  }
  return a;
}

int main(){
  while(cin.getline(s,100)){
    f=false;
    i=0;
    pii r=pp();
    if(f){
      cout<<"overflow"<<endl;
    }else{
      if(r.first==0&&r.second==0){
	cout<<0<<endl;
      }else{
	if(r.first){
	  cout<<r.first;
	}
	if(r.second){
	  if(r.first&&r.second>0){
	    cout<<'+';
	  }
	  cout<<r.second<<'i';
	}
	cout<<endl;
      }
    }
  }
  return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * @author: Mackenzie
**/
#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mx_Pos = 1e3 + 5;
const int mx_Mask = (1 << 13);
const int INF = 1e9;
ll n, m;
ll lim;
vector<ll> S;
vector<ll> C;
ll memo[mx_Pos][mx_Mask];
ll dp(ll pos, ll mask) {
    //cout << pos << " " << mask << " " << currentCost << endl;
    if (pos == m) {
        if (mask == lim) return 0;
        return INF;
    }

    ll &ans = memo[pos][mask];
    if (ans != -1) return ans;
    ans = INF;
    ans = min(dp(pos + 1, mask), dp(pos + 1, mask | S[pos]) + C[pos]);
    return ans;
}

int main() {
#ifdef LOCAL
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    memset(memo, -1, sizeof memo);
    cin >> n >> m;
    lim = (1 << n) - 1;
    forn(i, m) {
        ll ci, bi;
        cin >> ci >> bi;
        ll subset = 0;
        forn(i, bi) {
            ll vi;
            cin >> vi;
            subset += (1 << (vi - 1));
        }
        S.pb(subset);
        C.pb(ci);
    }
    ll ans = dp(0, 0);
    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;
    return 0;
}

Measured memory_bytes: 64640
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MM = 1000000000;
#define mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
#define MAX 10000000005
#define NIL -1
int main(){
    ll n, p; cin >> n >> p;
    ll ans = 1;
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    ll a = 1;
    while(pow(a, n) <= p){
        ll i = pow(a, n);
        if(p % i == 0) ans = a;
        a++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N = gets.to_i

Ns = N.to_s

An = (Ns[0].to_i) * (10 ** (Ns.length - 1)) - 1

def aaa(n, a)
    if n < 1 then
        return a
    end
    a += n % 10
    return aaa(n / 10, a)
end

aaan = aaa(N, 0)
aaaa = aaa(An, 0)

if aaan < aaaa then
    puts aaaa
else
    puts aaan
end

Measured memory_bytes: 1788
#include<stdio.h>
#define MAX 2000000

int H,A[MAX + 1];

void maxHeapify(int i){
  int tmp,l,r,largest;
  l = 2*i;
  r = 2*i + 1;
  if(l <= H && A[l] > A[i])largest = l;
  else largest = i;
  if(r <= H && A[r] > A[largest])largest = r;
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}

int main(){
  int i;
  scanf("%d",&H);
  
  for(i = 1 ; i <= H ; i++){
    scanf("%d",&A[i]);
  }
  
  for(i = H/2 ; i >= 1 ; i--){
    maxHeapify(i);
  }

  for(i = 1 ; i <= H ; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



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

const int N = 100005;

int n, d[N][2];
vector<int> e[N];

int f(int x, int y, int z){
    if(d[x][y] >= 0) return d[x][y];
    if(y == 0 && e[x].size() > 2) return d[x][y] = N;
    if(e[x].size() == 1) return d[x][y] = y;
    int r = 0, m = 0;
    for(int i : e[x]){
        if(i == z) continue;
        if(y == 0) return d[x][y] = f(i, y, x);
        int a = f(i, 0, x);
        int b = f(i, 1, x);
        r += b;
        if(!a) m = max(m, b);
    }
    return d[x][y] = r - (e[x].size() > 2) * m;
}

int main(){
    scanf("%d", &n);
    for(int i = 0, x, y; i < n - 1; i++){
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    for(int i = 0; i < n; i++) d[i][0] = d[i][1] = -1;
    for(int i = 0; i < n; i++) if(e[i].size() > 2){
        printf("%d\n", f(i, 1, -1));
        return 0;
    }
    puts("1");
}

Measured memory_bytes: 11520
X = input()
xlst = []
xlst.append(X[0])
for i in range(1, len(X)):
    if X[i] == 'S':
        xlst.append(X[i])
    else:
        if xlst != [] and xlst[-1] == 'T':
            xlst.append(X[i])
        elif xlst != [] and xlst[-1] == 'S':
            xlst.pop()
        else:
            xlst.append(X[i])

print(len(xlst))


Measured memory_bytes: 5096
import math
n = int(input())
a = list(map(int,input().split()))
mx = max(a)
b=[0] * 2000000
ans = 0
for i in range(len(a)):
    b[a[i]-1] += 1

for i in range(mx):
    if(b[i] == 0 or b[i] == 1):
        ans += 0
    else:
        ans = ans + int(b[i] * (b[i]-1)/2)
ans1 = 0


for i in range(len(a)):
    ans1 = ans
    if(b[a[i]-1] >2):
        ans1 = ans1 -int((b[a[i]-1]*(b[a[i]-1]-1))/2) + int(((b[a[i]-1]-1) * (b[a[i]-1]-2))/2)
        print(int(ans1))
    elif(b[a[i]-1] == 2):
        print(int(ans1-1))
    elif(b[a[i]-1] < 2):
        print(int(ans1))

Measured memory_bytes: 31844
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define endl '\n'
const int mod=1e9+7,u=1e5+5;

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

    int n;
    cin>>n;
    vector<int> a(n+1),b(n+1),c(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }   

    int dp[3][n+1];
    dp[0][0]=0;
    dp[1][0]=0;
    dp[2][0]=0;

    for(int i=1;i<=n;i++){
        dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a[i];
        dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b[i];
        dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c[i];
    }
    cout<<max({dp[0][n],dp[1][n],dp[2][n]});

    return 0;
}

Measured memory_bytes: 4992
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b,c,d,n;
  cin>>a>>b>>c>>d>>n;
  ll na=a*4,nb=b*2;
  ll mn=min(na,min(nb,c));
  if(n%2==0) cout<<min(n/2*d,n*mn)<<endl;
  else cout<<min((n/2)*d+mn,n*mn)<<endl;
}

Measured memory_bytes: 256
N = int(input())
h = list(map(int,input().split()))

dp_num = []
dp_num.append(0)
dp_num.append(abs(h[1]-h[0]))
for i in range(2,N):
  tmp = min(dp_num[i-2]+abs(h[i]-h[i-2]),dp_num[i-1]+abs(h[i]-h[i-1]))
  dp_num.append(tmp)
print(dp_num[N-1])

Measured memory_bytes: 13980
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int x=1;
	for(int i=0;i<n;i++){
		x = min(x+k, 2*x);
	}

	cout<< x <<endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }

int main(void) {
	ll n; cin >> n;
	ll y;
	ll x=y=n;
	for (ll i = 1; i*i <= n; i++) {
		ll t = n;
		if (t % i == 0) {
			t /= i;
			if (t + i < x + y) {
				x = i;
				y = t;
			}
		}
	}
	cout << x + y - 2 << endl;



	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=mpowe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}

int main()
{
    fastio();
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    ll n,m;
    cin>>n>>m;
    if(n==m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h> 
#include<iostream> 
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N=2e5+20;
const int MAX=10000007;
inline ll read() {
    char c=getchar();ll x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0',c=getchar();}
    return x*f;
}
inline void out(ll x) {   
    if(x>9) out(x/10);   
    putchar(x%10+'0'); 
} 

int q[N];
int mp[1000005];
bool mp1[1000005];
int main(){
    int n;
    int x;
    x=read();
    n=read();
    rep(i,1,n){
        q[i]=read();
        mp[q[i]]++;
    }
    int maxx=INF;
    int ans=0;
    rep(i,0,200){
        if(mp[i]!=0)continue;
        if(abs(x-i)<maxx){
            maxx=abs(x-i);
            ans=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}
/*
 */

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
signed main(){
  int N,K; cin>>N>>K;
  vi A(N);
  rep(i,0,N) cin>>A[i];
  int ans=MOD;
  if(A[N-1]<0)
    ans=-A[N-K];
  else{
    int X=distance(A.begin(),lower_bound(ALL(A),0));
    if(X>=K)
      ans=-A[X-K];
    rep(i,max(X,K-1),min(N,X+K)){
      int P=A[i],Q=A[i-K+1];
      int sum=P-Q;
      sum+=min(abs(P),abs(Q));
      ans=min(ans,sum);
      }
    }
  cout<<ans<<endl;
  }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

main() {
    int n, q;
    string s;
    cin >> n >> s >> q;

    for (auto i : irange(0, q)) {
        int k;
        cin >> k;

        int64_t num_d = 0;
        int64_t num_m = 0;
        int64_t num_dm = 0;
        int64_t ans = 0;
        for (auto pos : irange(0, n)) {
            auto c = s[pos];
            if (c == 'D') {
                ++num_d;
            } else if (c == 'M') {
                ++num_m;
                num_dm += num_d;
            } else if (c == 'C') {
                ans += num_dm;
            }

            if (pos - k + 1 < 0) {
                continue;
            }
            auto prev = s[pos - k + 1];
            if (prev == 'D') {
                --num_d;
                num_dm -= num_m;
            } else if (prev == 'M') {
                --num_m;
            }
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 1412
using static System.Console;
using static System.Convert;
class Program
{
    static void Main(string[] args)
    {
        var num1 = ToDouble(ReadLine());
        var num2 = ToDouble(ReadLine());
        if (num1 > num2) WriteLine("GREATER");
        else if (num1 < num2) WriteLine("LESS");
        else WriteLine("EQUAL");
    }
}


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

typedef long long ll;

#define rep0(i, n) for(ll i=0; i<(ll)(n); i++)
#define rep1(i, n) for(ll i=1; i<=(ll)(n); i++)
#define rep(i, a, b) for(ll i=(ll)a; i<=(ll)(b); i++)
#define rep0r(i, n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rep1r(i, n) for(ll i=(ll)(n); i>0; i--)
#define repr(i, a, b) for(ll i=(ll)b; i>=(ll)(a); i--)
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) a * b / __gcd(a, b)


void solve() {
    ll n;
    ll cnt[200010] = {};
    cin >> n;

    rep(i, 2, n) {
        ll x = 0;
        cin >> x;
        cnt[x]++;
    }

    rep1(i, n) {
        cout << cnt[i] << '\n';
    }
}

signed main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+1;
const int inf = 0x7fffffff;

//int n,m,a[N],b[N],c[N],d[N];
bool can[3001];
int can1[3001];

double mx;
int main()
{
	double a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	double ans1=100*a,ans2=0;
	for(int i=0;i<=3000;++i)
	{
		if(i>=a)can[i]|=can[i-(int)a];
		if(i>=b)can[i]|=can[i-(int)b];
	}
	can1[0]=1;
	for(int i=0;i<=3000;++i)
	{
		if(i>=c)can1[i]|=can1[i-(int)c];
		if(i>=d)can1[i]|=can1[i-(int)d];
	}
	for(int i=0;i<=30;++i)
	for(int j=0;j<=30;++j)
	{
		if(i==0&&j==0)continue;
		int ta=i*a*100+j*b*100;
		if(ta<=f)
		{
			for(int k=0;k<=300;++k)
			for(int l=0;l+k<=300;++l)
			{
				if(k*c+l*d+ta<=f)
				{
					double x;
					x=(double)(k*c+l*d)/(double)(k*c+l*d+ta);
					if(x>mx&&x*(e+100.0)<=e)
					mx=x,ans2=k*c+l*d,ans1=k*c+l*d+ta;
				}
			}
		}
	}
	cout<<ans1<<" "<<ans2;
}

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

neg = 0
for a in A:
    if a<0:
        neg+=1
        
A = [abs(a) for a in A]        
A.sort()

if neg%2==1:
    A[0] = -1*A[0]

print(sum(A))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	int x, y, z, k;
	ll a[1333], b[1333], c[1333];
	cin>>x>>y>>z>>k;
	REP(i, x){
		cin>>a[i];
	}
	REP(i, y){
		cin>>b[i];
	}
	REP(i, z){
		cin>>c[i];
	}
	ll ab[1252525];
	REP(i, x){
		REP(j, y){
			ab[i*y+j]=a[i]+b[j];
		}
	}
	sort(ab, ab+(x*y), greater<ll>());
	ll abc[3252525];
	REP(i, k){
		REP(j, z){
			abc[i*z+j]=ab[i]+c[j];
		}
	}
	sort(abc, abc+(k*z), greater<ll>());
	REP(i, k){
		cout<<abc[i]<<'\n';
	}
	return 0;
}


Measured memory_bytes: 35456
N,M = map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()

if N==1:
  print(X[M-1]-X[0])
elif N>=M:
  print(0)
else:
  Y=list()
  [Y.append(X[i]-X[i-1]) for i in range(M)[1:]]
  Y.sort()
  print(sum(Y[:-(N-1)]))


Measured memory_bytes: 13832
N = int(input())
L = list(map(int, input().split()))
L.reverse()
ans = "Yes"
for n in range(N-1):
  if L[n] < L[n+1]:
    if L[n] == L[n+1]-1:
      L[n+1] = L[n+1]-1
    else:
      ans = "No"

print(ans)

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

int main(){
  int n;cin >> n;int p[n+1];for(int i=0;i<n;i++)cin >> p[i];
  /*for(int i=0;i<n-1;i++){
    if(p[i] > p[i+1])ans += 1;
  }
  if(ans <= 2)cout << "YES" << endl;
  else cout << "NO" << endl;*/
  int sum = 0,ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      swap(p[i],p[j]);
      for(int k = 0;k < n - 1;k++){
        if(p[k] < p[k+1])sum += 1;
      }
      if(sum == n - 1){
        cout << "YES" << endl;
        return 0;
      }
      swap(p[i],p[j]);
      sum = 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
import bisect
N,M=map(int,input().split())
A=[[]for i in range(N)]
L=[]

for i in range(M):
    P,Y=map(int,input().split())
    A[P-1].append(Y)
    L.append([P-1,Y])
#print(A)
#print(L)

for j in range(N):
    A[j].sort()
#print(A)

for k in range(len(L)):
    ans1=str((L[k][0]+1)+1000000)
    ans1=ans1[1:]
    ans2=bisect.bisect_left(A[L[k][0]],L[k][1])
    ans2=str(ans2+1+1000000)
    ans2=ans2[1:]
    print(ans1+ans2)

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();


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


    m= max (0LL , m+ min (0LL, n-k) );
    n= max (0LL, n-k);


    cout << n <<" " <<m << '\n';

    return 0;
}



Measured memory_bytes: 3548
import heapq
N, M, R = map(int, input().split())

class Route:
    def __init__(self, B, C):
        self.next = points[B]
        self.distance = C
class Point:
    def __init__(self, id):
        self.id = id
        self.neighbors = []
        self.clear()
    def clear(self):
        self.distances = [-1] * 2
    def set(self, cur):
        self.distances[cur.srcid] = cur.distance
        return self.isWent(0) and self.isWent(1)
    def isWent(self, n):
        return self.distances[n] >= 0
    def addNeighbor(self, B, C):
        self.neighbors.append(Route(B, C))
    def optimize(self):
        self.neighbors = sorted(self.neighbors, key=lambda obj:obj.distance)

class MeetInfo:
    def __init__(self):
        self.clear()
    def clear(self):
        self.distance = -1
    def isMet(self):
        return self.distance >= 0

class Cursor:
    def __init__(self, ri, pt, meetinfo, dist=0):
        self.srcid = ri
        self.point = pt
        self.cur_route = 0
        self.distance = dist
        self.meetinfo = meetinfo
        if self.point.set(self):
            meetinfo.distance = self.point.distances[0] + self.point.distances[1]

    def cost(self):
        while self.cur_route < len(self.point.neighbors):
            rt = self.point.neighbors[self.cur_route]
            if not rt.next.isWent(self.srcid):
                break
            self.cur_route+= 1
        else:
            return None

        return self.distance + rt.distance

    def progress(self):
        nextrt = self.point.neighbors[self.cur_route]
        addcursor(Cursor(self.srcid, nextrt.next, self.meetinfo, self.distance + nextrt.distance))
        self.cur_route += 1
        addcursor(self)
    def __lt__(self, other):
        return True
points = [Point(i) for i in range(N+1)]

in_r = [ri for ri in map(int, input().split())]
for A, B, C in (map(int, input().split()) for _ in range(M)):
    points[A].addNeighbor(B, C)
    points[B].addNeighbor(A, C)

for x in points:
    x.optimize()

def addcursor(cur):
    c = cur.cost()
    if not c is None:
        heapq.heappush(hq, (c, cur))

def getRs(rs = None, cnt = -1, ret = None):
    if rs is None:
        rs = [False] * R
        ret = []
        cnt = R

    if cnt <= 0:
        yield ret
        return

    cnt -= 1

    for i in range(R):
        if not rs[i]:
            rs[i] = True
            ret.append(i)
            yield from getRs(rs, cnt, ret)
            ret.pop()
            rs[i] = False

Rmatrix = [[-1 for _ in range(R)] for _ in range(R) ]

for i in range(R):
    for j in range(R):
        if i >= j:
            continue

        meetinfo = MeetInfo()
        for x in points:
            x.clear()
        rs = [Cursor(i, points[ri], meetinfo)  for i, ri in enumerate((in_r[i], in_r[j]))]
        hq = []
        addcursor(rs[0])

        while not meetinfo.isMet():
            cost, cursor = heapq.heappop(hq)
            cursor.progress()

        Rmatrix[i][j] = meetinfo.distance
        Rmatrix[j][i] = meetinfo.distance

M = 10 ** 9
for r in getRs():
    #print(r)
    w = 0
    for i in range(R-1):
        w += Rmatrix[r[i]][r[i+1]]    
    M = min(M, w)

print(M)


Measured memory_bytes: 10996
n = int(input())
T = 45
F = 19
a = [[0 for i in range(F)] for j in range(T)]
p = pow(10,9)
two_size = 18
five_size = 18
count = 0
for i in range(n):
    s = input()
    if '.' in s:
        index = s.index('.')
        s += '0' * (  9 - (len(s) - 1 - index))
        s = s.replace('.','')
    else :
        s += '0' * 9
    k = int(s)
    two = 0
    five = 0
    while k % 2 == 0:
        two += 1
        k //= 2
    while k % 5 == 0:
        five += 1
        k //= 5
    t, f = two_size - two, five_size - five
    for x in range(t, T):
        for y in range(f, F):
            count += a[x][y]
    a[two][five] += 1
print(count)

Measured memory_bytes: 77532
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};

//ll mod = 1000000009;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

/*
int main() {
        int n; string s, t; cin >> n >> s >> t;
        int I, J;
        for(int i = 0; i < n; i++){
            bool ok = true;
            for(int j = 0; j < n; j++){
                if(s[i]==t[j]){
                    I = i; J = j;
                    while(I < n-1){
                        if(s[I+1] == t[J+1]){
                            I++; J++;
                        }else{
                            ok = false;
                            break;
                        }
                    }
                }
            }if(ok){
                rep(k,I) cout << s[k];
                for(int k = J; k < n; k++) cout << t[k];
                return 0;
            }
        }
}
*/
int main(){
    int n; string s, t; cin >> n >> s >> t;

    for(int i = 0; i < n; i++){
        bool ok = true; int k = 0,K;
        for(int j = i; j < n; j++){
            if(s[j] == t[k]) {k++; K = j;}
            else{
                ok = false;
                break;
            }
        }
        if(ok){
            //rep(l,K+1) cout << s[l];
            //for(int l = k;l < n;l++) cout << t[l];
            cout << K + n - k + 1 << endl;
            return 0;
        }
    }
    cout << 2 * n << endl;
}




Measured memory_bytes: 3632
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const size_t INF=1uLL<<57;

template <class RandomIt, class T=typename RandomIt::value_type>
vector<T> lisubseq(RandomIt first, RandomIt last) {
    size_t n=last-first;
    vector<T> seq(n, INF);
    for (size_t i=0; i<n; ++i)
        *lower_bound(seq.begin(), seq.end(), first[i]) = first[i];

    seq.erase(lower_bound(seq.begin(), seq.end(), INF), seq.end());
    return seq;
}

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

    vector<size_t> a(n);
    for (size_t i=0; i<n; ++i)
        scanf("%zu", &a[i]);

    printf("%zu\n", lisubseq(a.begin(), a.end()).size());
    return 0;
}

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

bool check(int x){
  int t = x%10;
  x /= 10;
  while(x > 0){
    if(x%10 != t-1) return false;
    t = x%10;
    x /= 10;
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  int ans = -1;
  for(int i = 0; i < N; ++i){
    for(int j = 0; j < i; ++j){
      int x = A[i]*A[j];
      if(check(x)) ans = max(ans, x);
    }
  }
  cout << ans << endl;
}



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

int main() {

    int n, miss, ans;
    string a, b, c;
    
    cin >> n >> a >> b >> c;
    
    ans = 0;

    for(int i = 0; i < n; i++) {
        miss = 0;
        if(a.at(i) != b.at(i)) miss++;
        if(b.at(i) != c.at(i)) miss++;
        if(c.at(i) != a.at(i)) miss++;

        if(miss > 0) ans += miss - 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

/**
 * ZAKIREN第5章 4-6.データ構造の応用
 * 
 * @author tdi5277
 *
 */
public class Main {
	/** 入力用 */
	private static Scanner scan = new Scanner(System.in);

	/** 出力用 */
	private static StringBuilder stringBuilder = new StringBuilder();

	/**
	 * 文字列から配列を生成します。
	 * @param size 配列のサイズ
	 * @param arrayStr 配列にしたい数字を空白繋ぎにした文字列
	 * @return 配列
	 */
	private static int[] generateArray(int size, String arrayStr) {
		int[] array = new int[size];
		Arrays.fill(array, 0);
		String[] temp = arrayStr.split(" ");
		for (int i = 0; i < size; i++) {
			array[i] = Integer.parseInt(temp[i]);
		}
		Arrays.sort(array);
		return array;
	}
	
	/**
	 * メイン。
	 * 
	 * @param args 未使用
	 */
	public static void main(String[] args) {
		// 読み込み
		int n       = Integer.parseInt(scan.nextLine());
		String strS = scan.nextLine();
		int q       = Integer.parseInt(scan.nextLine());
		String strT = scan.nextLine();
		
		// 読み込み終了
		scan.close();
		scan = null;

		// 配列を生成
		int[] arrayS = generateArray(n, strS);
		int[] arrayT = generateArray(q, strT);
		
		// 同じものを含む個数を計算
		int count = 0;
		for (int i = 0; i < arrayS.length; i++) {
			if (i > 0 && arrayS[i] == arrayS[i - 1]) {
				continue;
			}
			for (int j = 0; j < arrayT.length; j++) {
				if (j > 0 && arrayT[j] == arrayS[j - 1] ||
						arrayS[i] < arrayT[j]) {
					continue;
				}
				if (arrayS[i] == arrayT[j]) {
					count++;
				}
			}
		}

		// 結果出力 合計
		stringBuilder.append(count);

		System.out.println(stringBuilder.toString());

	}

}



Measured memory_bytes: 31744
import std.algorithm, std.stdio;

void main() {
  long N, W;
  readf(" %d %d ", &N, &W);
  
  auto weights = new long[N];
  auto values  = new long[N];
  
  foreach (i; 0..N) {
    readf(" %d %d ", &weights[i], &values[i]);
  }
  
  const V = values.sum;
  
  long[][] dp;
  dp.length = N+1;
  foreach (ref x; dp) x.length = V+1;
  
  foreach (ref x; dp) x[] = long.max/2;
  dp[0][0] = 0;
  
  foreach (i; 0..N) foreach (j; 0..V+1) {
    if (j - values[i] >= 0) dp[i+1][j] = min(dp[i+1][j], dp[i][j-values[i]]+weights[i]);
    dp[i+1][j] = dp[i+1][j].min(dp[i][j]);
  }
  
  foreach_reverse (v; 0..V+1) {
    if (dp[N][v] <= W) {
      v.writeln;
      break;
    }
  }
}


Measured memory_bytes: 81404
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back

using namespace std;
typedef pair<ll,ll> pll;

ll n, m;
ll s[12];
ll p[12];
int main()
{
        cin >> n >> m;
        for(ll i=1;i<=m;i++) {
                ll k;
                cin >> k;
                s[i] = 0;
                while(k--){
                        ll x;
                        cin >> x;
                        x--;
                        s[i] |= (1LL << x);
                }
        }
        ll ans = 0;
        for(ll i=1;i<=m;i++) cin >> p[i];
        for(ll mask=0;mask<(1LL << n);mask++) {
                bool ok = true;
                for(ll i=1;i<=m;i++) {
                        ll yo = mask&s[i];
                        ll pp = __builtin_popcountll(yo);
                        pp %= 2;
                        if(pp != p[i]) ok =false;
                }
                if(ok) ans++;
        }
        cout<<ans << endl;
        return 0;
}


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


struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
 ll n,m,k;
 cin>>n>>m>>k;
 UnionFind uf(n);
 vector<vector<ll> > g(n),r(n);
 for(ll i=0;i<m;i++){ 
  ll a,b;
  cin>>a>>b;
  a--,b--;
  uf.unite(a,b);
  g[a].push_back(b);
  g[b].push_back(a);
 }

 for(ll i=0;i<k;i++){ 
  ll a,b;
  cin>>a>>b;
  a--,b--;
  r[a].push_back(b);
  r[b].push_back(a);
 }

 for(ll i=0;i<n;i++){
  ll res = uf.size(i);
  for(ll j=0;j<r[i].size();j++){
   if( uf.find(i) == uf.find(r[i][j]) ) res --;
  }
  res--;
  if( i != 0 )cout<<' ';
  cout<<res-g[i].size();
 }
 cout<<endl;
    return 0;
}


Measured memory_bytes: 13300
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

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

	vector<int> X,Y;
	int tmpX,tmpY;
	vector<int> current;
	for(int i=0;i<M;i++){
		cin>>tmpX>>tmpY;
		X.push_back(tmpX);
		Y.push_back(tmpY);
	}

	vector<int> Box;
	
	for(int i=0;i<N;i++){
		Box.push_back(1);
	}
	vector<int> cand;
	set<int> cand2;
	cand2.insert(0);
	cand.push_back(0);
	for(int i=0;i<M;i++){
		if(Box[X[i]-1]>0) {
			Box[X[i]-1]--;
			Box[Y[i]-1]++;
		}

		auto iter=cand2.find(X[i]-1);

		if(iter!=cand2.end() && Box[Y[i]-1]>0){
			cand2.insert(Y[i]-1);
		}

		if(iter!=cand2.end() && Box[X[i]-1]==0){
			cand2.erase(iter);
		}

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


Measured memory_bytes: 6132
//minamoto
#include<bits/stdc++.h>
#define R register
#define inline __inline__ __attribute__((always_inline))
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=1e5+5;
int a[105],f[2][N],g[2][N],inv[N],n,k,t,res,tmp;
int main(){
	scanf("%d%d",&n,&k);
	fp(i,1,n)scanf("%d",&a[i]);
	inv[0]=inv[1]=1;fp(i,2,k)inv[i]=mul(P-P/i,inv[P%i]);
	f[t=0][0]=1,g[0][0]=0;
	fp(i,1,n){
		fp(j,0,k)f[t^1][j]=f[t][j],g[t^1][j]=g[t][j];
		fp(j,0,k-a[i]-1){
			if(f[t][j])upd(g[t^1][j+a[i]+1],f[t][j]);
			if(g[t][j])upd(f[t^1][j+a[i]+1],g[t][j]);
		}
		t^=1;
//		printf("%d\n",i);
	}
	tmp=1;
//	fp(i,0,0)printf("%d %d %d\n",i,f[t][i],g[t][i]);
	for(R int i=0;i<=k;++i,tmp=1ll*tmp*(i+n-1)%P*inv[i]%P)res=add(res,mul(tmp,dec(f[t][k-i],g[t][k-i])));
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 2176
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;

#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()



int main() {
    IOS;
	
	int a,b,c;
	cin >> a >> b >> c;
	int q = a+b+c - max(max(a,b),c) - min(min(a,b),c);
	cout << max(max(a,b),c) - q + q - min(min(b,c),a);

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
long long Comb(int n, int r)
{
	//n, rが負またはn<rの時は失敗
	if(n<0||r<0||n<r) return 0;

	//nCr=nCn-r
	r=(n<n-r)?n:(n-r);

	//r=0,1の時は計算する必要がない
	if(r==0) return 1;
	if(r==1) return n;

	vector<int> numerator(r), denominator(r);

	for(int k=0; k<r; k++){
		numerator[k]=n-r+k+1;
		denominator[k]=k+1;
	}

	for(int p=2; p<=r; p++){
		int pivot=denominator[p-1];
		if(pivot>1){
			int offset=(n-r)%p;
			for(int k=p-1; k < r; k+=p){
				numerator[k-offset]/=pivot;
				denominator[k]/=pivot;
			}
		}
	}

	long long result=1;
	for(int k=0; k<r; k++){
		if(numerator[k]>1) result*=numerator[k];
	}
	return result;
}
int main(void)
{
	int n, p, ev=0, odd;

	ll ans=0;

	cin>>n>>p;

	vi a(n);

	rep(i, n){
		cin>>a[i];
		if(a[i]%2==0) ev++;
	}

	odd=n-ev;

	//iは全体で選ぶ個数
	rep(i, n+1){
		if(p){
			//i個のうちj個が奇数
			rep(j, i+1){
				if(j%2==1){
					ans+=Comb(odd, j)*Comb(ev, i-j);
				}
			}
		}else{
			//i個のうちj個が奇数
			rep(j, i+1){
				if(j%2==0){
					ans+=Comb(odd, j)*Comb(ev, i-j);
				}
			}
		}
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;

}

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

using namespace std;

int main() {
  
  int N,counter;
  cin >> N;
  
  for (int i=0; i < N; i++){
    
    string S;
    cin >> S;
    
    if (S == "Y"){
      counter ++;
    }
    
    else{
      counter += 0;
    }
  }
  
  if (counter > 0){
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }   
      
}


Measured memory_bytes: 256