akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<string>
#include<numeric>
#include<set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using vi = vector<int>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using vpii = vector<pii>;

int main(){
  int N;
  cin >> N;
  vi L(N);
  rep(i, N) cin >> L[i];

  stable_sort(L.begin(), L.end());
  long cnt = 0;
  
  rep_inv(ia, N-1, 1){
    rep_inv(ib, ia-1, 0){
      int Lc = L[ia] - L[ib];
      int left = 0;
      int right = ib - 1;
      int mid;

      if(L[left] > Lc) cnt += (long)(ib);
      else if(L[right] <= Lc) cnt += 0;
      else{
	while(true){
	  mid = left + (right - left) / 2;

	  if(L[mid] > Lc && L[mid - 1] <= Lc) break;
	  else if(L[mid] <= Lc) left = mid + 1;
	  else if(L[mid - 1] > Lc) right = mid;
	}
	cnt += (long)(ib - mid);
      }
    }
  }

  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
n,x,m=map(int,input().split())

lis=[0]*m

ans=x
ai=x
lis[ai]=[1,ans]
flg=0

for i in range(2,n+1):
    ai=(ai**2)%m
    if lis[ai]!=0:
        start=lis[ai][0]
        goal=i-1
        span=goal-start+1
        sumspan=ans-lis[ai][1]+ai
        flg=1
        break
    ans+=ai
    lis[ai]=[i,ans]

if flg:
    times=(n-goal)//span
    last=(n-goal)%span
    ans+=sumspan*times
    #print(last)
    #print(sumspan*times)
    if last==1:
        ans+=ai
    for i in range(0,last-1):
        ans+=ai
        #print(i)
        ai=(ai**2)%m
        if i == last-2:
            ans+=ai
    print(ans)
else:
    print(ans)

Measured memory_bytes: 17108
N = int(input())
s = []
for i in range(N):
    s.append(input())

M = int(input())
t = []
for i in range(M):
    t.append(input())

money = 0
money_list = []
word_list = list(set(s+t))
for i in range(len(word_list)):
    sum = s.count(word_list[i])
    sum -= t.count(word_list[i])
    if sum < 0:
        sum = 0
    money_list.append(sum)

money_list.sort(reverse = True)
print(money_list[0])


Measured memory_bytes: 3064
from collections import Counter
from operator import mul
from functools import reduce

N = int(input())

line = [int(x) for x in input().split()]
counter = Counter(line)

collect = {key: int(value * (value - 1) / 2)
           for key, value in counter.items()}
min_collect = {key: int((value - 1) * (value - 2) / 2)
               for key, value in counter.items()}

max_value = sum(collect.values())

for i in line:
    print(min_collect[i] + max_value - collect[i])


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


void solve(){
    int n; 
    cin >> n;
    string s;
    cin >> s;
    s = s + "X";
    int p[n+10];
    rep(i,n){
      p[i]=0;
    }
    rep(i,n){
      if(i!=0&&s[i]=='E') p[0]++;
    }
    for(int i=1; i<n; i++){
      p[i] = p[i-1];
      if(s[i-1]=='W') p[i]++;
      if(s[i]=='E') p[i]--;
    }
    int ans = INF;
    rep(i,n){
      ans =min(ans,p[i]);
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1900
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>

using namespace std;
using llng = long long;

/* Declarations */
int A, B;

void solve() {
    A = (A+11) % 13;
    B = (B+11) % 13;
    if (A == B) {
        cout << "Draw" << endl;
    } else if (A > B) {
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }
}
int main() {
    cin >> A >> B;

    solve();

    return 0;
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"strings"
)

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var (
		n int
		s string
	)
	fmt.Scan(&n, &s)

	c1, c2 := 0, 0
	for _, r := range s {
		if r == '(' {
			c1++
		} else {
			if c1 > 0 {
				c1--
			} else {
				c2++
			}
		}
	}

	fmt.Println(strings.Repeat("(", c2) + s + strings.Repeat(")", c1))
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
    char c;

    cin >> c;

    if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u') {
        cout << "vowel" << endl;
    } else {
        cout << "consonant" << endl;
    }

    return 0;
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string S;
signed main() {
    cin >> S;
    int ans = 0;
    rep(i, S.length() / 2) {
        if (S[i] != S[S.length() - i - 1]) { ans++; }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var output = [];
  for( var i=0; i<data.length; i++ ) {
    var mfr = data[i].split( ' ' );
    var m = parseInt( mfr[0] );
    var f = parseInt( mfr[1] );
    var r = parseInt( mfr[2] );
    
    if( -1 == m && -1 == f &&  -1 == r ) { break; }
    
    var sum = m+f;
    if( -1 == m || -1 == f ) {
      output.push( "F" );
    } else if( 80 <= sum ) {
      output.push( "A" );
    } else if( 65 <= sum && sum < 80 ) {
      output.push( "B" );
    } else if( 50 <= sum && sum < 65 ) {
      output.push( "C" );
    } else if( 30 <= sum && sum < 50 ) {
      if( 50 <= r ) {
        output.push( "C" );
      } else {
        output.push( "D" );      
      }
    } else {
      output.push( "F" );
    }
  }
  console.log( output.join( '\n' ) );
});

Measured memory_bytes: 7644
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

N,d=gets.chomp.split(' ').map{|n| n.to_i}
A = Array.new(N)
0.upto(N-1){|d|
	A[d],dum=gets.chomp.split(' ').map{|n| n.to_i}
}
B = Array.new(N)
0.upto(N-1){|d|
	B[A[d]-1]=d
}

cnt = 0
n = -1
cnt_max = 0
0.upto(N-1){|i|
	if(B[i] > n)
		cnt += 1
		n = B[i]
	else
		if(cnt_max < cnt)
			cnt_max = cnt
		end
		cnt = 1
		n = B[i]
	end
}
if(cnt_max < cnt)
	cnt_max = cnt
end

puts N-cnt_max



Measured memory_bytes: 5500
#include<bits/stdc++.h>
using namespace std;
int n;
const int maxn=1e5+5;
char a[maxn];
int pos[maxn];

int main() {
	scanf("%s",a);
	int len=strlen(a);
	int num1=0,num2=0,res=0 ;
	for(int i=0; i<=len; i++) {
		if(a[i]=='R')num1++,pos[res]+=num2,num2=0,res=0;
		if(a[i]=='L') {
			pos[i-1]+=num1,num1=0,num2++;
			if(!res)res=i;
		}
	}
	pos[res]+=num2;
//	for(int i=0;i<len;i++)printf("%d ",pos[i]);
//	puts("");
	for(int i=0; i<len-1; i++) {
		if(pos[i]&&pos[i+1]&&(pos[i]>=2||pos[i+1]>=2)) {
			int res=pos[i]+pos[i+1];
			if(res%2==0)pos[i]=pos[i+1]=res/2;
			else {
				int mx=max(pos[i],pos[i+1]);
				mx--;
				if(pos[i]<pos[i+1])pos[i]=res/2,pos[i+1]=res/2+1;
				else pos[i]=res/2+1,pos[i+1]=res/2;
				if(mx%2!=0)swap(pos[i],pos[i+1]);
			}
			i++;
		}
	}
	for(int i=0; i<len; i++)printf("%d ",pos[i]);
	return 0;
}

Measured memory_bytes: 896
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, A, B) = read!(usize, usize, usize);

    let s = N / (A + B);
    let t = N % (A + B);
    let x = s * A + min(t, A);

    println!("{}", x)
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
	int x,y,w,h,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if( x-r<0 || y-r<0 || x+r>w || y+r>h )
		printf("No\n");
	else printf("Yes\n");
	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#define xx first 
#define yy second
using namespace std;
inline int read()
{
	int k=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) k=k*10+c-'0';return f*k;
}
typedef pair<int,int> P;
const int N=200055;
int n,fa[N];
map<P,int> mp;
multiset<int> G[N];
queue<P> q;
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
void add(int a,int b)
{
	G[a].insert(b);
	G[b].insert(a);
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
		fa[i]=i;
	for(int i=1;i<=(n-1)<<1;i++)
	{
		int a,b;
		a=read();b=read();
		if(a>b) swap(a,b);
		add(a,b);
		P e=P(a,b);
		mp[e]++;
		if(mp[e]==2) 
			q.push(e);
		else if(mp[e]>2)
			{puts("NO");return 0;}
	}
	for(int i=1;i<n;i++)
	{
		if(q.empty()) {puts("NO");return 0;}
		int x=0,y=0;
		for(;x==y;x=find(q.front().xx),y=find(q.front().yy),q.pop());
		if(G[x].size()>G[y].size()) swap(x,y);
		fa[x]=y;
		for(multiset<int>::iterator it=G[x].begin();it!=G[x].end();it++)
		{
			int v=find(*it);	
			G[v].erase(G[v].find(x));
			if(v==y) continue;
			add(v,y);
			P e=P(v,y);
			if(v>y) swap(e.xx,e.yy);
			mp[e]++;
			if(mp[e]==2) q.push(e);
		}
		G[x].clear();
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 43776
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll k, a, b;
  cin >> k >> a >> b;

  ll ans = 1;
  ll ansb = 1;

  ll t = k - (a - 1) - 2;
  if (t >= 0) {
    ans = b;
    if (a < b) {
      ans += (t / 2) * (b - a);
      ans += t % 2;
    }
  }

  ansb += k;

  cout << max(ans, ansb) << ln;

  return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N;
	cin >> N;

	vector<ll> As(N);
	vector<ll> Bs(N);

	for (ll i = 0; i < N; ++i) {
		cin >> As[i];
	}
	for (ll i = 0; i < N; ++i) {
		cin >> Bs[i];
	}

	vector<pair<ll, ll>> ABs(N);
	for (ll i = 0; i < N; ++i) {
		ABs[i] = make_pair(Bs[i], As[i]);
	}
	sort(ABs.begin(), ABs.end());

	vector<pair<ll, ll>> A_index_pairs(N);
	for (ll i = 0; i < N; ++i) {
		A_index_pairs[i] = make_pair(ABs[i].second, i);
	}

	sort(A_index_pairs.begin(), A_index_pairs.end());

	for (ll i = 0; i < N; ++i) {
		if (A_index_pairs[i].first > ABs[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	ll count = 0;
	ll index = 0;
	while (true) {
		index = A_index_pairs[index].second;
		++count;
		if (index == 0) {
			break;
		}
	}
	if (count < N) {
		cout << "Yes" << endl;
		return 0;
	}

	for (ll i = 0; i + 1 < N; ++i) {
		if (A_index_pairs[i + 1].first <= ABs[i].first) {
			cout << "Yes" << endl;
			return 0;
		}
	}

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


Measured memory_bytes: 4992
#include<cstring>
#include<iostream>
using namespace std;
int l1,l2,t1=0,t2=0;
char s1[51],s2[51];
int main()
{
	cin>>s1>>s2;
	l1=strlen(s1);
	l2=strlen(s2);
	for(int i=0;i<l1;i++)
	{
		if(i!=l1-1||l1==l2)cout<<s1[i]<<s2[i];
		if(i==l1-1&&l1!=l2)cout<<s1[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		int ans = 0;
		for (int i = 0; i < s.length(); i++) {
			if (!s.substring(i, i + 1).equals(t.substring(i, i + 1)))
				ans++;
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 55280
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node [] G = new Node[n];
        for(int i=0;i<n;i++){
            int id = sc.nextInt();
            int k = sc.nextInt();
            int child[] = new int[k];
            if(k!=0) for (int j = 0; j < k; j++) child[j] = sc.nextInt();
            Node node = new Node();
            node.element(id, -1, child, "leaf", 0);
            G[id] = node;
        }
        for(int i=0;i<n;i++) for(int j:G[i].child) G[j].parent = G[i].id;
        int root =0;
        for(Node g:G){
            if(g.child.length==0&&g.parent!=-1) g.type="leaf";
            else if(g.child.length!=0&&g.parent!=-1)g.type="internal node";
            else{
                g.type="root";
                root = g.id;
            }
        }
        int Check [] = new int[n];
        Arrays.fill(Check,0);
        BFS(G,root,Check,0);
        for(Node node :G){
            StringBuilder result = new StringBuilder();
            result.append("node "+node.id+": parent = "+node.parent+", depth = "+node.depth+", "+node.type+", [");
            if(node.child.length!=0) {
                result.append(node.child[0]);
                for (int i = 1; i < node.child.length; i++) result.append(", " + node.child[i]);
            }
            result.append("]");
            System.out.println(result);
        }
    }
    public static void BFS(Node [] G,int id,int [] C,int depth){
        G[id].depth=depth;
        C[id] = 1;
        if(G[id].child.length!=0) for(int i:G[id].child)  if(C[i]==0) BFS(G,i,C,depth+1);
    }
    public static class Node{
        int id;
        int parent;
        int [] child;
        String type;
        int depth;
        public void element(int id,int parent,int []child,String type,int depth){
            this.id = id;
            this.parent = parent;
            this.child = child;
            this.type = type;
            this.depth = depth;
        }
    }
}


Measured memory_bytes: 174160
// Problem : F - Playing Tag on Tree
// Contest : AtCoder Beginner Contest 148
// URL : https://atcoder.jp/contests/abc148/tasks/abc148_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inf LLONG_MAX
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n,u,v;cin>>n>>u>>v;
u--;v--;vi a[n];
for(int i=0;i<n-1;i++)
{
	int x,y;cin>>x>>y;
	x--;y--;
	a[x].pb(y);
	a[y].pb(x);
}
if(u==v)
{
	cout<<0;return;
}
int level1[n],level2[n];inin(level1);inin(level2);
queue<int> q,q1;
level1[u]=0;
q.push(u);
while(!q.empty())
{
	int x=q.front();
	q.pop();
	for(int i=0;i<a[x].size();i++)
	{
		if(level1[a[x][i]]==-1)
		{
			level1[a[x][i]]=level1[x]+1;
			q.push(a[x][i]);
		}
	}
}
q=q1;level2[v]=0;
q.push(v);
while(!q.empty())
{
	int x=q.front();
	q.pop();
	for(int i=0;i<a[x].size();i++)
	{
		if(level2[a[x][i]]==-1)
		{
			level2[a[x][i]]=level2[x]+1;
			q.push(a[x][i]);
		}
	}
}
int ans=0;
for(int i=0;i<n;i++)
if(a[i].size()==1 && level1[i]<level2[i])
ans=max(ans,level2[i]-1);
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
while(t--)
{
    solve();
}
}


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

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> a(n);
        for (int &ai: a) cin >> ai;
        int sum = accumulate(a.begin(), a.end(), 0);
        double ave = 1.0 * sum / n;
        int cnt = 0;
        for (int i = 0; i < n; i++) if (a[i] <= ave) cnt++;
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>

using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	
	int res = 0;
	if (k > a) res += a;
	else {
		cout << k << '\n';
		return 0;
	}
	if (k > a + b) res += 0;
	else {
		cout << res << '\n';
		return 0;
	}
	if (k > a + b + c) res -= c;
	else {
		cout << res - (k - a - b) << '\n';
		return 0;
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

/**
 * Calculator
 */
public class Main{

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

        while (true) {
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
            if (op.equals("+")) {
                System.out.println(a + b);
            } else if (op.equals("-")) {
                System.out.println(a - b);
            } else if (op.equals("/")) {
                System.out.println(a / b);
            } else if (op.equals("*")) {
                System.out.println(a * b);
            } else if (op.equals("?")) {
                break;
            } else {
                System.out.println("opは+ - * / ? のいずれかにしてください。");
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 26380
#include <stdio.h>

int main(){
	int n,k,l;
	if(scanf("%d %d", &n, &k)==EOF){return 0;}
	
	int sticks[n];
	
	for(int i = 0; i < n ; i++){
		if(scanf("%d", &l)==EOF){return 0;}
		sticks[i] = l;
	}

	int temp;
	int max = 0;
	for(int i = 0; i < n-2 ; i++){
		for(int j = 0; j < n-1-i; j++){
			if(sticks[j] > sticks[j+1]){
				temp = sticks[j];
				sticks[j] = sticks[j+1];
				sticks[j+1]  = temp; 
			}
		}
		/*
		printf("[");
		for(int j = 0; j < n; j++){printf("%d, ", sticks[j]);}
		printf("]\n");
		*/
	}
	
	for(int i = 0; i< k; i++){max += sticks[n-1-i];}
	
	printf("%d\n", max);
	return 0;

}

Measured memory_bytes: 1736
#include <stdio.h>

int ans[11][331] = {{0}};

void solve(int n, int s, int bit)
{
	int i;
	ans[n][s]++;
	
	for (i = 0; i < 10; i++){
		if ((bit >> i) & 1){
			solve(n + 1, s + i * (n + 1), bit ^ (1 << i));
		}
	}
}

int main(void)
{
	int n, s;
	solve(0, 0, (1 << 10) - 1);
	
	while (scanf("%d%d", &n, &s) != EOF){
		printf("%d\n", (s <= 330 && n <= 10) ? ans[n][s] : 0);
	}
	
	return (0);
}

Measured memory_bytes: 296
#include<bits/stdc++.h>
using namespace std;
int main(){
  long N;cin>>N;
  vector<long>A(N);for(int i=0;i<N;i++)cin>>A[i];
  sort(A.begin(),A.end());
  vector<long>cumsum(N);cumsum[0]=A[0];
  for(int i=1;i<N;i++)cumsum[i]=cumsum[i-1]+A[i];
  
  vector<bool>ok(N);ok[N-1]=true;
  for(int i=0;i<N-1;i++){
    ok[i]=(cumsum[i]*2>=A[i+1]);
  }
  long ans=0;
  for(int i=N-1;i>=0;i--){
    if(ok[i])ans++;
    else {cout<<ans;return 0;}
  }
  cout<<ans;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (c <= a + b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21712
'use strict'

function main(input){

  const lines = input.split('\n');
  const N = parseInt(lines.shift());
  const C = [];
  const S = [];
  const F = [];
  for(let i=0;i<N-1;i++){
    let csf =lines[i].split(' ').map( x => parseInt(x)); 
    C.push(csf[0]);
    S.push(csf[1]);
    F.push(csf[2]);
  }

  let result = [];

  if(N==2){
    console.log(S[0]+C[0]);
    console.log(0);
    return;
  }
  if(N==1){
    console.log(0);
    return;
  }

  for(let i=0;i<N-1;i++){
    let current_start_time = S[i];
    for(let j=i;j<N-2;j++){
      let additional_wait_time = Math.max( 0, Math.ceil( (current_start_time+C[j]-S[j+1])/F[j+1] ) ) * F[j+1];
      current_start_time = S[j+1]+additional_wait_time;

//      console.log([current_start_time, additional_wait_time] );

    }
    current_start_time += C[N-2];
    result.push(current_start_time);
  }
  result.push(0);

  for(let i=0;i<N;i++){
    console.log(result[i]);
  }

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



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

using namespace std;

int main()
{
    long t,a,cnta=0,cnte=0;
    cin>>t;
    
    while(t--)
    {
        cin>>a;
        if(a%2==0)
        {
            cnte++;
            
            if(a%3==0 || a%5==0)
                cnta++;
        }
        
    }
    if(cnta==cnte)
        cout<<"APPROVED";
    else
        cout<<"DENIED";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int mod=1e9+7;
int main() {
string s,t;
cin>>s>>t;
char a,b;
int j=1;
for(int i=0;i<s.size();i++){
   if(s==t){
      cout<<"Yes"<<endl;
      return 0;
   }
   a=s.at(0);
   while(1){
      if(j==s.size()){
         s.at(0)=a;
         break;
      }
    else{  b=s.at(j);
      s.at(j)=a;
      a=b;
    }
    j++;
   }
   j=1;
}
cout<<"No"<<endl;
}


Measured memory_bytes: 256
/* Just_Do_It ___________ICARUS__________________*/
                     
    #include <bits/stdc++.h>
    using namespace std;
           
    typedef long long ll;
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define rep(i,a,n) for(int i=a;i<n;i++)
    #define per(i,n,a) for (int i=n;i>a;i--)
    #define te int t; std::cin >> t; while(t--)
    #define SZ 200010
    //# define M_PIl  3.141592653589793238462643383279502884L 
    /*   Proceed with CAUTION   */

    int main(){
        fastio;
        ll a[3];
        rep(i,0,3) cin>>a[i];
        sort(a,a+3);
        ll s  = a[0]+a[1]+a[2]*10;
        cout<<s<<endl;
    }	

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int w,h,x,y,r;
	scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
	if(x-r>=0&&x+r<=w&&y-r>=0&&y+r<=h)printf("Yes\n");
	else printf("No\n");
	return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define ff first
#define ss second
#define mod 1000000007
 
int rep = -1;
int nodes = 0;
int t_nodes = 0;
int ans = 1;
void dfs(vector<int> &g,int v,vector<bool> &vis)
{
    vis[v] = true;
    t_nodes++;
    if(!vis[g[v]])
    dfs(g,g[v],vis);
    else
    {
        rep = g[v];
        return;
    }
    return;
}
void dfs1(vector<int> &g,int v,vector<bool> &vis)
{
    vis[v] = true;
    nodes++;
    if(!vis[g[v]])
    dfs1(g,g[v],vis);
    return;
}
void dfs2(vector<int> &g,int v,int x)
{
    if(x == 0)
    {
        ans = v;
        return;
    }
    x--;
    dfs2(g,g[v],x);
}

int32_t main() 
{
    IO;
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vector<int> g(n+1,-1);
    vector<bool> vis(n+1,false);
    for(int i=0;i<n;i++)
    {
        g[i+1] = a[i];
    }
    dfs(g,1,vis);
    // cout<<rep;
    vector<bool> vis1(n+1,false);
    dfs1(g,rep,vis1);
    // cout<<t_nodes<<" "<<nodes;
    if(t_nodes - nodes >= k)
    {
        dfs2(g,1,k);
        cout<<ans;
    }
    else
    {
        int x = k - (t_nodes - nodes);
        x = x%nodes;
        dfs2(g,rep,x);
        cout<<ans;
    }
	return 0;
}


Measured memory_bytes: 6372
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
using namespace std;

int main()
{
	string s;
	cin >> s;
	if ((s[0] >= 'A') && (s[0] <= 'Z')) {
		cout << 'A' << endl;
	}
	else {
		cout << 'a' << endl;
	}
	return 0;
}

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

// using namespace __gnu_pbds;
using namespace std;

#define fbo find_by_order
#define ook order_of_key
#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());

// /mnt/c/Users/vince/Desktop/POST-IOI/  

int main()
{
	// ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);

	int n; scanf("%d", &n);
	int res = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; i*j < n; j++)
			res++;
	}
	printf("%d\n", res);
}

Measured memory_bytes: 3824
import sys
import numpy as np

readline = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int, readline().split()))

    base0 = A[0]
    base1 = sum(A) - base0

    ans = abs(base1 - base0)

    for i in range(1,N-1):
        base0 += A[i]
        base1 -= A[i]
        ans = min(abs(base1 - base0), ans)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32716
n = gets.chomp.to_i
ary = gets.split(" ").map(&:to_i)
 
if ary.size == 1
    puts "Yes"
    exit
end
 
(n-1).downto(1) do |i|
    if  ary[i] < ary[(i-1)]
        ary[(i-1)] -= 1
        if ary[i] < ary[(i-1)]
            puts "No"
            exit
        end
    end
end

puts ary == ary.sort ? "Yes" : "No"


Measured memory_bytes: 10104
#include <bits/stdc++.h>
#include <atcoder/math>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;
using namespace atcoder;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

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

  rep(ti,T) {
    ll N, M, A, B;
    cin >> N >> M >> A >> B;
    cout << floor_sum(N, M, A, B) << endl;
  }

  return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifdef LOCAL
#define dbg(...) {cerr << "> "; ZZ(#__VA_ARGS__,__VA_ARGS__);}
template <typename Arg1> void ZZ(const char* val1, Arg1&& arg1) { cerr << val1 << ": " << arg1 << endl; }
template <typename Arg1, typename... Args> void ZZ(const char* vals, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(vals + 1, ',');
    std::cerr.write(vals, comma - vals) << ": " << arg1<<" , ";
    ZZ(comma+1, args...);
}
#else
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;

int f[10][10];

signed main(){
    IOS;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int j = i;
        int r = j % 10;
        while (j / 10 != 0) {
            j /= 10;
        }
        f[j][r]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int j = i;
        int r = j % 10;
        while (j / 10 != 0) {
            j /= 10;
        }
        ans += f[r][j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
#define For1(i,n) for(ll i=1;i<(n);i++)
int main(void){
    ll n;cin>>n;
    vector<double> x(n),y(n);
    For(i,n) cin>>x.at(i)>>y.at(i);
    double ans=0;
    double p=M_PI/180;
    For(i,360){
        double cosi=cos(i*p),sini=sin(i*p);
        double xi=0,yi=0;
        For(j,n){
            if(cosi*x.at(j)+sini*y.at(j)>=0){
                xi+=x.at(j);
                yi+=y.at(j);
            }
        }
        ans=max(xi*xi+yi*yi,ans);
    }
    cout<<setprecision(12)<<sqrt(ans)<<endl;
}


Measured memory_bytes: 256
N, K = gets.split(' ').map(&:to_i)
MOD = 10 ** 9 + 7
tree = Array.new(N + 1){Array.new}
(N - 1).times do
	a, b = gets.split(' ').map(&:to_i)
	tree[a].push(b)
	tree[b].push(a)
end

color = [1] + [K] * N
queue = [1]
while queue.size > 0
	pos = queue.shift
	if pos == 1
		remain = K - 1
	else
		remain = K - 2
	end
	tree[pos].each do |nxt|
		if color[nxt] == K && nxt != 1
			color[nxt] = remain
			remain -= 1
			queue.push(nxt)
		end
	end
end

puts color.inject{|a, b| (a * b) % MOD}

Measured memory_bytes: 12796
n = int(input())
s = input()
Alphabet = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]
h = 0
for j in range(1,n):
    StringL = s[0:j]
    StringR = s[j:n]
    r = 0
    for i in Alphabet:
        if StringL.count(i) == 0:
            pass
        else:
            if StringR.count(i) == 0:
                pass
            else: r = r + 1
        if r > h:
            h = r
print(h)

Measured memory_bytes: 3188
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#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=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<ll> nums(3, 0);
    REP(i, N) {
        if(S[i] == 'R') nums[0]++;
        if(S[i] == 'G') nums[1]++;
        if(S[i] == 'B') nums[2]++;
    }

    ll tmp = nums[0] * nums[1] * nums[2];
    FOR(l, 1, (N+2)/2) {
        REP(i, N) {
            if(i + 2*l > N-1) continue;
            if(S[i] != S[i+l] && S[i+l] != S[i+2*l] && S[i] != S[i+2*l]) tmp--;
        }
    }

    cout << tmp << endl;

    return 0;
}

Measured memory_bytes: 3632
# include<iostream>
using namespace std;
const int MAX = 100;
const int INFTY = (1 << 21);
const int WHITE = 0;
const int GREY = 1;
const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
	int u, minv;
	int d[MAX], p[MAX], color[MAX];

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
	}

	d[0] = 0;

	while (1) {
		minv = INFTY;
		u = -1;
		for (int i = 0; i < n; i++) {
			if (color[i] != BLACK && minv > d[i]) {
				minv = d[i];
				u = i;
			}
		}

		if (u == -1) break;
		color[u] = BLACK;

		for (int v = 0; v < n; v++) {
			if (color[v] != BLACK && M[u][v] != INFTY) {
				if (d[v] > M[u][v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GREY;
				}
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < n; i++) {
		if (p[i] != -1) sum += d[i];
	}

	return sum;
}

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int e; cin >> e;
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}

	cout << prim() << endl;

	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define rep(i,n) for(int i=0; i<n; i++)
#define pb(a) push_back(a)
#define mp make_pair

int main()
{

  string s;

  cin >> s;

  for(int i=0; i<s.length(); i++) cout << "x";

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn=2e5;
const int mod=998244353;
int n,k;
struct Seq{
	int l,r;
}a[15];
ll f[maxn+5],sf[maxn+5];
int main(){
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++)
		scanf("%d %d",&a[i].l,&a[i].r);
	f[1]=sf[1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<=k;j++){
			if(a[j].l>=i) continue;
			if(a[j].r>=i) f[i]=((f[i]+sf[i-a[j].l])%mod-sf[0]+mod)%mod;
			else f[i]=((f[i]+sf[i-a[j].l])%mod-sf[i-a[j].r-1]+mod)%mod;
		}
		sf[i]=(sf[i-1]+f[i])%mod;
	}
	printf("%lld\n",f[n]);
	return 0;
}


Measured memory_bytes: 4804
#include <cstdio>

const int MAX_N = 20005;
int nums[MAX_N];

int main() {
  int N;
  scanf("%d", &N);
  int F = (N + 1);
  for (int i = 0; i < N; ++i) {
    int t;
    scanf("%d", &t);
    t--;
    nums[t] = i;
  }
  for (int i = 0; i < N; ++i) {
    printf("%d", (i + 1) * F);
    if (i != N - 1) printf(" ");
  }
  printf("\n");
  for (int i = 0; i < N; ++i) {
    printf("%d", F * F - (i + 1) * F + nums[i]);
    if (i != N - 1) printf(" ");
  }
  printf("\n");
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static int h;
    public static int w;
    public static int x;
    public static int y;
    public static int res;
    public static boolean[][] b;
    public static void main(String[] args) throws Exception {
        while (sc.hasNext()) {
            w = sc.nextInt();
            h = sc.nextInt();
            
            if (w == 0 && h == 0) break;
            
            x = 0;
            y = 0;
            res = 0;
            b = new boolean[h][w];

            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    int n = sc.nextInt();
                    if (n == 0) {
                        b[i][j] = true;
                    } else {
                        b[i][j] = false;
                    }
                }
            }
            
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (b[i][j] == false) {
                        res++;
                        solve(i,j);
                    }
                }
            }
            
            System.out.println(res);
        }
    }
    
    public static void solve(int x, int y) {
        b[x][y] = true;
        int[] d = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};
        for (int i = 0; i < 8; i++) {
            int nx = x + d[i*2];
            int ny = y + d[i*2+1];
            if ( 0 <= nx && nx < h && 0 <= ny && ny < w && b[nx][ny] == false) {
                solve(nx, ny);
            }
        }
    }
}

Measured memory_bytes: 45772
#include <stdio.h>
#include <cmath>
#include <stdlib.h>
#include <algorithm>

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

    printf("%d %d", std::min(a,b),std::max(0,a+b-n));
    return 0;
}


Measured memory_bytes: 128
def main():
    n = int(stdinput())
    S = [*map(int, stdinput().split())]
    q = int(stdinput())
    T = [*map(int, stdinput().split())]

    S = sorted(S)

    c = 0
    for t in T:
        if binary_search(S, len(S), t):
            c += 1
    
    print(c)

def binary_search(S, n, t):
    left = 0
    right = n - 1
    
    # print(*S)

    while left <= right:
        mid = (left + right) // 2

        # print(*[t, left, right, mid])
        # print(*[t, S[mid]])
        
        if S[mid] == t:
            return True
        elif S[mid] > t:
            right = mid - 1
        else:
            left = mid + 1
    
    return False

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


Measured memory_bytes: 16716
use std::str::FromStr;
use std::fmt::Debug;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn solve(n: usize, x: u64, layer: &Vec<u64>, patty: &Vec<u64>) -> u64{
    if x == 0{
        return 0;
    }else if x == 1{
        if n == 0{
            return 1;
        }else{
            return 0;
        }
    }else if x <= layer[n-1]+1{
        return solve(n-1, x-1, layer, patty);
    }else if x == layer[n-1] + 2{
        return 1 + patty[n-1];
    }else if x <= 2*layer[n-1] + 2{
        return 1 + patty[n-1] + solve(n-1, x - 2 - layer[n-1], layer, patty);
    }else{
        return patty[n];
    }
}

fn main(){
    let line: Vec<u64> = read_as_vec();
    let (n, k) = (line[0], line[1]);
    let mut layer: Vec<u64> = vec![0;(n+1) as usize];
    let mut patty: Vec<u64> = vec![0;(n+1) as usize];
    layer[0] = 1;
    patty[0] = 1;
    for i in 1..(n+1) as usize{
        layer[i] = layer[i-1]*2+3;
    }
    for i in 1..(n+1) as usize{
        patty[i] = patty[i-1]*2+1;
    }

    let ans = solve(n as usize, k, &layer, &patty);
    println!("{}", ans);
}


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

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


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


ll p(ll x){
    if(x==0){return 1;}
    ll y=p(x/2);
    if(x%2==1){return y*y%MOD*2%MOD;}
    else{return y*y%MOD;}
}

int main() {
   ll N;
   cin >>N;
   vector<ll> x(N+1),y(N+1);
   repn(i,N) cin >>x[i]>>y[i];

   bool ch[300][300]={};

   ll ans=(p(N)-N-1)%MOD;

   repn(i,N)repn(j,N){
    if(i==j){continue;}

    if(ch[i][j]==1){continue;}

    vector<ll> line;
    
    repn(k,N){
        if((x[i]-x[j])*(y[j]-y[k])==(x[j]-x[k])*(y[i]-y[j])){line.push_back(k);}
     }

     ll K=line.size();

     rep(k,K)rep(l,K)ch[line[k]][line[l]]=1;

     ans=ans-p(K)+K+1;
     ans%=MOD;
    

   }

   if(ans<0){ans+=MOD;}

   cout <<ans;


}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<vector>
 
#define ll         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define arraysize(ar)  (sizeof(ar) / sizeof(ar[0]))
using namespace std;

int a[100005],flag=0;


void solve(){
    int  a,b,c;
    cin>>a>>b;

    vi v;
    int  x=a+b;
    int x1=a-b;
    int x2=a*b;

    
    c=max(x,x1);
    cout<<max(c,x2);

    

}
 
signed main(){

    
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t=1;
    //cin>>t;

     
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void){
  int i, j, k, n, x, c;
  while(1){
  scanf("%d %d", &n, &x);
  if(n == 0 && x==0)
    break;
  c = 0;
  for(i = 1;i <= n-2;i++){
    for(j = i+1;j <= n-1;j++){
      for(k = j+1;k <= n;k++){
        if(i + j + k == x)
        c++;
  }}}
    printf ("%d\n", c);
  }

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int)2e5+123

int s,w;
 
int main(){_
    cin >> s >> w;
       if(w>=s){
       	cout << "unsafe" << endl;
	   }else{
	   	cout << "safe" << endl;
	   }
}

Measured memory_bytes: 3628
o = input()
e = input()

ans =""
if len(o) > len(e):
    for i in range(len(e)):
        ans += o[i]
        ans += e[i]
    ans += o[-1]
else:
    for i in range(len(o)):
        ans += o[i]
        ans += e[i]

print(ans)


Measured memory_bytes: 9064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int nMax=1e5+10;
const long long INF=1e17;
int n,t,e;
long long x[nMax],f[nMax],g[nMax];
int main()
{
	scanf("%d%d%d",&n,&e,&t);
	for(int i=1;i<=n;i++)
		scanf("%lld",&x[i]);
	long long Min=INF;
	g[0]=-x[1]*2;
	int p=0;
	for(int i=1;i<=n;i++)
	{
		while(p<=i&&(x[i]-x[p+1])*2>=t)
			Min=min(Min,g[p++]);
		if(p<i)
			f[i]=f[p]+t;
		else
			f[i]=INF;
		f[i]=min(f[i],Min+x[i]*2);
		g[i]=f[i]-2*x[i+1];
	}
	printf("%lld\n",f[n]+e);
	return 0;
}

Measured memory_bytes: 2560
#from math import gcd
from fractions import gcd
def ExtGCD(a, b):
    if b == 0:
        return a, 1, 0
    else:
        d, x, y = ExtGCD(b, a % b)
        x -= (a // b) * y
        return d, y, x
def ModInv(a, mod):
    return ExtGCD(a, mod)[1] % mod
def lcm(a,b):
    return a*b//gcd(a,b)
def main():
    n=int(input())
    A=list(map(int,input().split()))
    mod=10**9+7
    lcm=A[0]
    for i in range(1,n):
        lcm = lcm * A[i] //gcd(lcm, A[i])
    ans=0
    for a in A:
        ans += lcm*ModInv(a,mod)%mod
    print(ans%mod)
main()

Measured memory_bytes: 6100
#include<bits/stdc++.h>
using namespace std;
int a[7]={100,101,102,103,104,105};
int dp[100005];
int main(){
	int x;
	scanf("%d",&x);
	memset(dp,0,sizeof(dp));
	for(int i=0;i<6;i++){
		for(int j=a[i];j<=x;j++){
			dp[j]=max(dp[j],dp[j-a[i]]+a[i]);
		}
	}
	//cout<<dp[x];
	if(dp[x]==x)
		puts("1");
	else puts("0"); 
	return 0;
}

Measured memory_bytes: 640