akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros)]

macro_rules! get{
    ($t:ty) => {
        {
            let cin = stdin();
            let mut cin = cin.lock();
            
            let token =
                cin.by_ref().bytes().map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();

            try!(token.parse::<$t>())
        }
    }
}

macro_rules! input{
    ($($id:ident: $t:ty),*) => {
        $(
            let $id = get!($t);
        )*;
    }
}

macro_rules! input_vec{
    ($id:ident: Vec<$t:ty>, $n:expr) => {
        let $id = (0..$n).map(|_| get!($t).unwrap()).collect::<Vec<$t>>();
    }
}

use std::io::{Read,stdin};
use std::str::*;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp;
use std::error::Error;


fn main(){
    while let Ok(_) = solve() {}
}

fn solve() -> Result<(),Box<std::error::Error>>{
    input!(n: u32, s: String);

    let mut ans = 0;

    for i in 0..n {
        unsafe {
            let t = s.slice_unchecked(i as usize, n as usize);
            let z = z_algorithm(&t.to_string());

            for j in 0..n-i {
                if z[j as usize] <= j as usize {
                    ans = cmp::max(ans, z[j as usize] as usize);
                }
            }
        }
    }
    
    println!("{}", ans);

    Ok(())
}

fn z_algorithm(s: &String) -> Vec<usize>{
    let n = s.len();
    let mut ret = vec![0; n];

    let s = s.chars().collect::<Vec<char>>();

    let mut j = 0;
    for i in 1..n {
        if i+ret[i-j] < j+ret[j] {
            ret[i] = ret[i-j];
        }else{
            let mut k = cmp::max(0, (j+ret[j]) as i32 - i as i32) as usize;
            while i+k < n && s[k] == s[i+k] {
                k += 1;
            }
            ret[i] = k;
            j = i;
        }
    }
    
    ret[0] = n;
    
    ret
}


Measured memory_bytes: 4352
n=int(raw_input())
s=raw_input()

temp=s.count("#")
if temp==0 or temp==n:
    print(0)
else:
    head=0
    tail=n-temp
    ret=tail+head
    for c in s:
        if c=="#":
            head+=1
        else:
            tail-=1
        temp2=head+tail
        if temp2<ret:
            ret=temp2
    print(ret)


Measured memory_bytes: 2948
#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int a[N], b[N], c[N], f[N][3];

int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
	    cin >> a[i] >> b[i] >> c[i];
	}
	
	f[0][0] = a[0];
	f[0][1] = b[0];
	f[0][2] = c[0];
	
	for(int i = 1; i < n; i++){
	    for(int j = 0; j < 3; j++){
	        if(j == 0)
	        f[i][j] = max(f[i-1][j+1],f[i-1][j+2]) + a[i];
	        else if(j == 1)
	        f[i][j] = max(f[i-1][j-1],f[i-1][j+1]) + b[i];
	        else
	        f[i][j] = max(f[i-1][j-2],f[i-1][j-1]) + c[i];
	    }
	}
	cout << max(f[n-1][0],max(f[n-1][1],f[n-1][2]));
}

Measured memory_bytes: 5912
# pragma GCC optimize("O3")
# include <bits/stdc++.h>
std::pair<int,int> DR[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
# define maxn 100005
# define ll long long
# define clock (clock() * 1000.0 / CLOCKS_PER_SEC)
# define rc(s) return cout << s,0
# define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
# define db(x) cerr << #x << " = " << x << '\n'
# define pb push_back
# define mp make_pair
# define sz(x) (int)((x).size())
# define int ll
using namespace std;

int n,a[100];

int32_t main(){_
    //freopen("input","r",stdin);
	cin >> n;
	a[0] = 2;a[1] = 1;
	for(int i = 2;i <= 86;i++) a[i] = a[i - 1] + a[i - 2];
	rc(a[n]);	
}



Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    long long h;
    cin >> h;
    long long logH = log(h) / log(2);
    long long ans = 0;
    for(int i = 0; i <= logH; i++){
        ans += pow(2, i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  lli a;
  char b[5];
  while (scanf("%lld %s", &a, b) != EOF)
  {
    for (int i = 0; i < 4; i++) b[i] -= '0';
    lli bb = (int)b[0] * 100 + (int)b[2] * 10 + (int)b[3];
    lli ans = a * bb / 100;

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

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

int main() {
      int H = 0, W = 0, N = 0, ans = 0;
      cin >> H >> W >> N;
      if ( H <= W){
            H = W;
      }
      if ( 0 == N % H) {
            ans = N / H;
      }
      else {
            ans = 1 + N / H;
      }
      cout << ans << endl;
      return 0;
}


Measured memory_bytes: 256
def main():
    string = input()
    target = input()
    result = False
    for _ in range(len(target)):
        if string == target:
            result = True
            break
        string = string[-1] + string[:-1]
    if result:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int y = sc.nextInt();
        
        int hukuzawa = 0;
        int higuchi = 0;
        int noguchi = 0;
      
        int i = 0;
        int j = 0;
        
        for(i = 0; i <= n ; i++){
          for(j = 0; j <= (n-i) ; j++){
            if(y == i*10000+j*5000+(n-i-j)*1000){
                    hukuzawa = i;
                    higuchi = j;
                    noguchi = n-i-j;
                    System.out.println(hukuzawa + " " + higuchi + " " + noguchi);
                    return;
              }else{
                 continue;
              }
          }
        }
      
      
       System.out.println(-1 + " " + -1 + " " + -1);
	}
}

Measured memory_bytes: 39564
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    REP(i,N) cin >> v[i];
    int ans = 0;
    sort(ALL(v));
    REP(i,K) ans += v[i];
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define umap unordered_map
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "YES": "NO") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 
const int mod = 1e9 + 7; 
const int inf = 0x3f3f3f3f;
 
template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second  << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; } 
 
int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x; cin >> x;
	cout << (x^1) << '\n';
}
 


Measured memory_bytes: 3592
n, h = gets.chomp.split.map(&:to_i)
d = []
am = 0

n.times do
  ai, bi = gets.chomp.split.map(&:to_i)
  am = [am, ai].max
  d << [ai, bi]
end

d.sort_by! {|_, b| b }

i = n - 1
while i >= 0 && h > 0 && am < d[i][1]
  h -= d[i][1]
  i -= 1
end

res = n - 1 - i
if h > 0
  d.sort_by! {|a, _| a }
  res += (h + d[-1][0] - 1) / d[-1][0]
end
puts res

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

int main(void) {
  int N;
  cin >> N;

  for (int i = 0; i < N; i++) {
    char S;
    cin >> S;
    if (S == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

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

using namespace std;
int main()
{
	int n;
	cin >> n;
	//vector<int> a(n);

	//for (int i = 0; i < n; i++) {
	//	cin >> a[i];
	//}

	if (n % 2 == 1) {
		float m;
		m = float(n);
		cout << ((m - 1) / 2 + 1) / m;
	}
	else {
		cout << 0.5;
	}
}

Measured memory_bytes: 380
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def abc169d_div_game():
    n = int(input())
    arr = factorization(n)
    cnt = 0
    for p, e in arr:
        if p == 1: continue
        for i in range(1, e+1):
            if e >= i:
                cnt += 1
                e -= i
            else:
                break
    print(cnt)

abc169d_div_game()

Measured memory_bytes: 9408
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPI(i,a,b) for(ll i=b-1;i>=a;i--)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(a,b) get<a>(b)
#define VI vector<int>
#define VLL vector<long long>

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

ll modI(ll a, ll m);
ll gcd(ll a, ll b);
ll powM(ll x, unsigned ll y, unsigned ll m);
void pairsort(int a[], int b[], int n);
void pairsortll(ll a[],ll b[],ll n);
ll logint(ll x,ll y);


ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powM(ll x,ll y,ll m)
{
    if(y==0) return 1;
    ll p=powM(x,y/2,m)%m;
    p=(p*p)%m;
    return (y%2==0)?p:(x*p)%m;
}

ll modI(ll a, ll m)
{
    ll m0=m,y=0,x=1;
    if(m==1) return 0;
    while(a>1)
    {
        ll q=a/m;
        ll t=m;
        m=a%m;
        a=t;
        t=y;
        y=x-q*y;
        x=t;
    }
    if(x<0) x+=m0;
    return x;
}

void pairsort(int a[],int b[],int n)
{
    pair<int,int> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

void pairsortll(ll a[],ll b[],ll n)
{
    pair<ll,ll> v[n];
    REP(i,0,n)
    {
        v[i].F=a[i];
        v[i].S=b[i];
    }
    sort(v,v+n);
    REP(i,0,n)
    {
        a[i]=v[i].F;
        b[i]=v[i].S;
    }
}

ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<=x;i++)
    {
        if(x<a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}

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

    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */

    ll q=1;
    //cin>>q;
    while(q--)
    {
        string s,t;
        cin>>s>>t;
        ll ns=s.size();
        ll nt=t.size();
        ll dp[ns][26];
        ll lst[26];
        REP(i,0,26) lst[i]=-1;
        REPI(i,0,ns)
        {
            lst[s[i]-'a']=i;
            REP(j,0,26) dp[i][j]=lst[j];
        }
        ll rep=0;
        ll cur=0;
        ll flag=0;
        REP(i,0,nt)
        {
            if(dp[0][t[i]-'a']==-1)
            {
                flag=1;
                break;
            }
            else if(dp[cur][t[i]-'a']==-1)
            {
                rep++;
                cur=0;
                i--;
            }
            else
            {
                cur=dp[cur][t[i]-'a']+1;
                if(cur==ns)
                {
                    cur=0;
                    rep++;
                }
            }
        }
        if(flag==1) cout<<-1;
        else
        {
            cout<<rep*ns+cur;
        }
    }

    return 0;
}


Measured memory_bytes: 20944
#include<bits/stdc++.h>
using namespace std;
 
#define cinsc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOR(i,k,n)  for(int64 i=k;i<(int64)n;i++)
#define FORr(i,k,n)  for(int64 i=(int64)k;i>=n;i--)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define FOREACHr(it, l) for (auto it = l.rbegin(); it != l.rend(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
#define SQ(x) ((x)*(x))
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//ONLINE_JUDGE   LOCAL
 
int64 powr(int64 x,int64 y,int64 p)  
{  
    int res = 1;    
    x = x % p; 
    if (x == 0) return 0;
    while (y > 0){   
        if (y & 1)  
            res = (res*x) % p;   
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return res;  
} 
 
void  in_o(){
#ifndef LOCAL
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	cinsc;
}


int main(){
	//in_o();
	int n;
	cin>>n;
	int64 T=0,px=0,py=0;
	FOR(i,0,n){
		int64 t,x,y;
		cin>>t>>x>>y;
		int64 dt=t-T;
		int64 dx=abs(px-x)+abs(y-py);
		if(dx>dt || (dt-dx)%2==1){
			return cout<<"No"<<endl,0;
		}
		T=t;
		px=x;
		py=y;
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl(), c = inl();
        vl x(n), v(n);
        rep(i, n) x[i] = inl(), v[i] = inl();
        ll dl[n + 1], dr[n + 1];
        dl[0] = 0, dr[0] = 0;
        rep(i, n) dl[i + 1] = dl[i] + v[i];
        rep(i, n) dr[i + 1] = dr[i] + v[n - 1 - i];

        ll dp1[n + 1], dp2[n + 1];
        dp1[0] = 0, dp2[0] = 0;

        rep(i, n) {
            dp1[i + 1] = max(dp1[i], dl[i] + v[i] - x[i]);
            dp2[i + 1] = max(dp2[i], dr[i] + v[n - 1 - i] - (c - x[n - i - 1]));
        }
        ll ans = 0;
        rep(i, n + 1) {
            ans = max(ans, dp1[i] + dp2[n - i] - (i == 0 ? 0 : x[i - 1]));
            ans = max(ans, dp1[i] + dp2[n - i] - (i == n ? 0 : (c - x[i])));
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

using namespace std;

int main()
{
    int D, L;
    cin >> D >> L;

    if (D % L == 0) cout << D / L << endl;
    else {int a = D / L;
    int ans = D - a * L + a;
    cout << ans << endl;
    }
}


Measured memory_bytes: 3124
#include <stdio.h>
#include <stdlib.h>
int main(){
int t[100000],x[100000],y[100000];
int N;
scanf("%d",&N);
for(int k=0;k<N;k++){
scanf("%d %d %d",&t[k],&x[k],&y[k]);
}
if(t[0]<abs(x[0])+abs(y[0])||(t[0]-abs(x[0])+abs(y[0]))%2==1){
printf("No");
return 0;
}
for(int k=1;k<N;k++){
if(t[k]-t[k-1]<abs(x[k]-x[k-1])+abs(y[k]-y[k-1])||((t[k]-t[k-1])-abs(x[k]-x[k-1])+abs(y[k]-y[k-1]))%2==1){
printf("No");
return 0;
}
}
printf("Yes");
return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    int n;
    cin>>n;
    vector<int> v(n,0);
    for(int i = 0;i < n; i++){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    cout<<v[v.size()/2]-v[v.size()/2-1]<<endl;
    return 0;
}

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

int main(){
  ll a, b, k;
  cin >> a >> b >> k;
  if(a > k) cout << a-k << " " << b << endl;
  else cout << 0 << " " << max((ll)0,b-k+a) << endl; 
  return 0;
}

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

int H, W, N;
int ans[110][110];
vector<int> color;

signed main() {
    //cin.tie(0); ios::sync_with_stdio(false);
    cin >> H >> W >> N;
    rep(i, N) {
        int a; cin >> a;
        rep(j, a) color.pb(i+1);
    }
    int now = 0;
    rep(i, H) {
        if (i%2==0) {
            rep(j, W) {
                ans[i][j] = color[now];
                now++;
            }
        }
        else {
            for (int j=W-1; j>=0; j--) {
                ans[i][j] = color[now];
                now++;
            }
        }
    }
    rep(i, H) {
        rep(j, W) {
            if (j<W-1) cout << ans[i][j] << " ";
            else cout << ans[i][j] << endl;
        }
    }
}

Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int k, x;
	cin >> k >> x;
	if (500 * k >= x) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    string ans="APPROVED";
    int tmo=0;
    rep(i,n){
        cin>>tmo;
        if(tmo%2==0){
            if(!(tmo%3==0||tmo%5==0))ans="DENIED";
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    LL N;
    R(N);
    LL an=1e18;
    FOR(i,1,1000000){
        if(N%i==0){
            an=min(an,N/i+i-2);
        }
    }
    W(an);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

object Main extends App{
  val sc = new Scanner(System.in)

  val s = sc.next

  val res1 = s.zipWithIndex.forall{case (ch, i) =>
    i match {
      case j if j % 2 == 0 => ch != 'L'
      case _ => ch != 'R'
    }
  }

  val res = if(res1) "Yes" else "No"

  println(res)

}

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


Measured memory_bytes: 2604
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll S;
ll acc[1000001];

ll f(ll n) {
  if (n%2==0) {
    return n/2;
  }

  return 3 * n + 1;
}

void input() {
  cin >> S;
  acc[1] = S;
  loop(a,2,1000001) {
    acc[a] = f(acc[a-1]);
    loop(a_n, 1, a) {
      if (acc[a_n] == acc[a]) {
        cout << a << endl;
        return;
      }
    }
  }
}

int main() {
  // cout.precision(15);
  input();
  return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, M, ans = 0;
	cin >> N >> M;
	pair<int, int> AB;
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> a;
	for (int i = 0; i < N; ++i) {
		cin >> AB.first >> AB.second;
		a.push(AB);
	}
	priority_queue<pair<int, int>> b;
	for (int i = 1; i <= M; ++i) {
		while (!a.empty() && a.top().first == i) {
			b.emplace(a.top().second, a.top().first);
			a.pop();
		}
		if (!b.empty()) {
			ans += b.top().first;
			b.pop();
		}
	}
	cout << ans;
}

Measured memory_bytes: 2548
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;

int n, m;
int a[305][305];
bool used[305];
int cnt[305];
bool check(int x) 
{
	memset(cnt, 0, sizeof(cnt));
	memset(used, 0, sizeof(used));
	for(int i = 1; i <= n; i++) a[i][0] = 1;
	while(true)
	{
		int num = -1;
		for(int i = 1; i <= n; i++) {
			int now = a[i][0];
			cnt[a[i][now]]++;
			if(cnt[a[i][now]] > x)
				num = a[i][now];
		}
		if(num == -1) 
			return 1;
		used[num] = 1;
		for(int i = 1; i <= n; i++) {
			while(a[i][0] <= m && used[a[i][a[i][0]]] == 1) {
				a[i][0]++;
			}
			if(a[i][0] > m) return 0;
		}

		memset(cnt, 0, sizeof(cnt));
	}
}

int main()
{
	while(scanf("%d %d", &n, &m) != EOF)
	{
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= m; j++) {
				scanf("%d", &a[i][j]);
			}
			a[i][0] = 1;
		}
		int l = 0, r = n;
		int mid = 0;
		int ans = 0;
		while(l <= r) 
		{
			mid = (l + r) >> 1;
			if(check(mid)) ans = mid, r = mid - 1;
			else l = mid + 1;
		}
		printf("%d\n", ans);

		memset(a, 0, sizeof(a));
	}
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		int A, B; cin >> A >> B;
		if (!A)break;
		vector<vector<pair<int, int>>>pluss(10002), minuss(10002);
		for (int i = 0; i < A; ++i) {
			int l, u, r, d; cin >> l >> u >> r >> d;
			l++;  r++;
			pluss[u].push_back(make_pair(l, r));
			minuss[d].push_back(make_pair(l, r));
		}

		vector<int>v(10002);
		int area = 0;
		int circ = 0;
		for (int y = 0; y < 10001; ++y) {
			vector<int>nextv(v);
			for (auto p : pluss[y]) {
				for (int x = p.first; x < p.second; ++x) {
					nextv[x]++;
				}
			}
			for (auto p : minuss[y]) {
				for (int x = p.first; x < p.second; ++x) {
					nextv[x]--;
				}
			}
			for (int i = 0; i < 10002; ++i) {
				if (nextv[i])area++;
				if (bool(nextv[i]) != bool(v[i]))circ++;
				if (i&&(bool(nextv[i]) != bool(nextv[i - 1])))circ++;
			}
			v = nextv;
		}
		cout << area << endl;
		if (B == 2)cout << circ << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		int n = Integer.parseInt(str[0]);
		long x = Long.parseLong(str[1]);

		System.out.println(solve(n, x));
	}

	static long solve(int n, long x) {
		if (n == 0)
			return 1;
		long len = (1L << (n + 1)) - 3;
		long num = (1L << n) - 1;
		if (x == 1)
			return 0;
		else if (x <= len + 1)
			return solve(n - 1, x - 1);
		else if (x == len + 2)
			return num + 1;
		else if (x <= (len + 1) * 2)
			return num + 1 + solve(n - 1, x - len - 2);
		else
			return num * 2 + 1;
	}
}

Measured memory_bytes: 32784
//B - Card Game for Two:
//Assunto: 
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, a = 0, b = 0;
    cin >> n;
    vector<int> cards(n);
    loop(i, 0, n) cin >> cards[i];
    sort(rall(cards));
    for(int i = 0; i < n; i += 2) a += cards[i];
    for(int i = 1; i < n; i += 2) b += cards[i];
    cout << a - b << "\n";
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int q = Integer.parseInt(sc.next());
    int[] count = new int[n + 1];
    Edge[] to = new Edge[n + 1];
    for (int i = 1; i <= n; i++) {
      to[i] = new Edge();
    }
    for (int i = 0; i < n - 1; i++) {
      int a = Integer.parseInt(sc.next());
      int b = Integer.parseInt(sc.next());
      to[a].add(b);
      to[b].add(a);
    }
    for (int i = 0; i < q; i++) {
      int p = Integer.parseInt(sc.next());
      int x = Integer.parseInt(sc.next());
      count[p] += x;
    }
    propagateCount(1, count, to);
    pw.println(
      Arrays.stream(count, 1, n + 1)
        .mapToObj(c -> String.valueOf(c))
        .collect(Collectors.joining(" ")));
  }

  static void propagateCount(int nodeId, int[] count, Edge[] to) {
    boolean[] exclude = new boolean[count.length + 1];
    exclude[nodeId] = true;
    propagateCountRecursively(count[nodeId], nodeId, count, to, exclude);
  }

  static void propagateCountRecursively(int parentCount, int nodeId, int[] count, Edge[] to,
    boolean[] exclude) {
    for (int child : to[nodeId].edge) {
      if (exclude[child]) {
        continue;
      }
      exclude[child] = true;
      count[child] += parentCount;
      propagateCountRecursively(count[child], child, count, to, exclude);
    }
  }

  static class Edge {

    private List<Integer> edge = new ArrayList<>();

    void add(int node) {
      edge.add(node);
    }
  }
}


Measured memory_bytes: 164960
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main() {
	char S[200001];
	while (~scanf("%s", S)) {
		int n = (int)strlen(S);
		int cnt[26] = {};
		ll ans = 1;
		rep(i, n) {
			int a = S[i] - 'a';
			ans += i - cnt[a];
			++ cnt[a];
		}
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
int INF = 1e16+7;
typedef pair<int,int> P;
signed main(){
    int N;
    cin >> N;
    vector<vector<P>>road(N);
    for(int i = 0; i < N-1; i++) {
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        road[a].push_back({b,c});
        road[b].push_back({a,c});
    }
    int Q,K;
    cin >> Q >> K;
    K--;
    priority_queue<P,vector<P>,greater<P>> que;
    vector<int>cnt(N,INF);
    cnt[K] = 0;
    que.push({0,K});
    while(!que.empty()) {
        P x = que.top();
        que.pop();
        if(cnt[x.second] < x.first) {
            continue;
        }
        for(int i = 0; i < road[x.second].size(); i++) {
            if(cnt[road[x.second][i].first] > x.first+road[x.second][i].second) {
                cnt[road[x.second][i].first] =  x.first+road[x.second][i].second;
                que.push({cnt[road[x.second][i].first],road[x.second][i].first});
            }
        }
    }
    for(int i = 0; i < Q; i++) {
        int x,y;
        cin >> x >> y;
        x--;y--;
        cout << cnt[x]+cnt[y] << endl;
    }
}




Measured memory_bytes: 13948
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Eric
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FFrogJump solver = new FFrogJump();
        solver.solve(1, in, out);
        out.close();
    }

    static class FFrogJump {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            long[] arr = new long[n];
            for (int i = 0; i < n; i++)
                arr[i] = in.nextLong();
            //long res = solveSimple(n, arr);
            long res = solveMeOk(n, arr);
            out.println(res);
        }

        private long solveMeOk(int n, long[] arr) {
            HashSet<Integer> used = new HashSet<>();
            long res = 0;
            //n-1 = a+(k-1)c
            for (int c = 1; c < n; c++) {
                used = new HashSet<>();
                long score = 0;
                res = Math.max(res, score);
              used.add(0); used.add(n-1);
                for (int k = 1; k * c < n - 1; k++) {
                    if (n-1-k*c<c)
                      break;
                    if (k * c == n - 1 - k * c)
                        break;
                    if (used.contains(k * c) || used.contains(n - 1 - k * c))
                        break;
                    score += arr[k * c] + arr[n - 1 - k * c];
                    used.add(k * c);
                    used.add(n - 1 - k * c);
                    res = Math.max(score, res);
                }
            }
            return res;
        }

    }
}



Measured memory_bytes: 109532
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
using CostType = long long;
struct Edge {
  int src, dst; CostType cost;
  Edge(int src, int dst, CostType cost = 0) : src(src), dst(dst), cost(cost) {}
  inline bool operator<(const Edge &rhs) const {
    return cost != rhs.cost ? cost < rhs.cost : dst != rhs.dst ? dst < rhs.dst : src < rhs.src;
  }
  inline bool operator<=(const Edge &rhs) const { return cost <= rhs.cost; }
  inline bool operator>(const Edge &rhs) const {
    return cost != rhs.cost ? cost > rhs.cost : dst != rhs.dst ? dst > rhs.dst : src > rhs.src;
  }
  inline bool operator>=(const Edge &rhs) const { return cost >= rhs.cost; }
};

vector<vector<Edge> > graph(100000);
int color[100000] = {};
void dfs(int par, int ver, bool black) {
  for (Edge e : graph[ver]) if (e.dst != par) {
    if (e.cost % 2 == 0) {
      color[e.dst] = (black ? 0 : 1);
      dfs(ver, e.dst, black);
    } else {
      color[e.dst] = (black ? 1 : 0);
      dfs(ver, e.dst, !black);
    }
  }
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  REP(i, n - 1) {
    int u, v, w; cin >> u >> v >> w; --u; --v;
    graph[u].emplace_back(Edge(u, v, w));
    graph[v].emplace_back(Edge(v, u, w));
  }
  dfs(-1, 0, true);
  REP(i, n) cout << color[i] << '\n';
  return 0;
}


Measured memory_bytes: 10624
using System.Linq;
using static System.Console;

class Program {
	static void Main() {
		var L = new long[] { 2, 1 };
		var N = int.Parse(ReadLine());

		for (var i = 2; i <= N; i++) {
			L[i % 2] = L.Sum();
		}
		WriteLine(L[N % 2]);
	}
}

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

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

	int r = 0;
	for (int i = 0; i < N; i++)
	{
		if (s[i] == 'R') {
			r++;
		}
		
	}
	if (r > N / 2) {
		cout << "Yes";

	}
	else {
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<stack>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline char gc(){
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	return getchar();
}
inline int read(){
	int ans=0,fh=1;
	char ch=gc();
	while(ch<'0'||ch>'9'){if(ch=='-') fh=-1; ch=gc();}
	while(ch>='0'&&ch<='9')	ans=(ans<<1)+(ans<<3)+ch-'0',ch=gc();
	return ans*fh;
}
ll n,p;
int main(){
//	freopen("1.in","r",stdin);
	scanf("%lld%lld",&n,&p);
	ll sq=sqrt(p);
	ll ans=1;
	for(ll i=2;i<=sq;i++)
		if(p%i==0){
			ll cnt=0;
			while(p%i==0) cnt++,p/=i;
			cnt/=n;
			while(cnt--) ans*=i;
		}
	if(p>1&&n==1) ans*=p; 
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int energy,y,z,conse;
	int barrier,maxb;
	try{
	    while(0!=(conse=Integer.valueOf(br.readLine()))){
		maxb = 1000000;
		if(!(Math.pow(z=(int)Math.cbrt(conse),3.0)<=conse&&z>1.0))z = 0;
		do{
		    barrier = z;
		    energy = conse-(z*z*z);
		    if(Math.pow(y=(int)Math.sqrt(energy),2.0)<=energy&&y>1.0){
			energy-=(y*y);
			barrier += y;
		    }else y = 0;
		    barrier += energy;
		    if(barrier<maxb){
			maxb = barrier;
		    }
		    z--;
		}while(z>=0);
		System.out.println(Integer.toString(maxb));
	    }
	}
	catch(Exception e){
	    System.exit(0);
	}
    }
}

Measured memory_bytes: 22432
S = input()

def M(x):
  if 1 <= int(x) <= 12:
    return 1
  else:
    return 0

L = M(S[:2])
R = M(S[2:])

if L == 1:
  if R == 1:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if R == 1:
    print("YYMM")
  else:
    print("NA")

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

using namespace std;

#define MAX 5010
#define INF 1e9
#define F first
#define S second
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
 
int N,K;
pii taxi[MAX];
vector<int> G[MAX];
int cost[MAX][MAX];

int dijkstra(){
  priority_queue<piii,vector<piii>,greater<piii> > Q;
  Q.push(piii(pii(0,0),0));
  fill(cost[0],cost[0]+MAX*MAX,INF);
  cost[0][0] = 0;

  while(!Q.empty()){
    piii p = Q.top(); Q.pop();
    int v = p.F.S, r = p.S;
    if(cost[v][r] < p.F.F) continue;

    if(r > 0){
      for(int i = 0 ; i < (int)G[v].size() ; i++){
        int to = G[v][i];
        if(cost[v][r] < cost[to][r-1]){
          cost[to][r-1] = cost[v][r];
          Q.push(piii(pii(cost[to][r-1],to),r-1));
        }
      }
    }
    pii t = taxi[v];
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      int to = G[v][i];
      if(cost[v][r] + t.F < cost[to][t.S-1]){
        cost[to][t.S-1] = cost[v][r] + t.F;
        Q.push(piii(pii(cost[to][t.S-1],to),t.S-1));
      }
    }
  }
  
  return *min_element(cost[N-1],cost[N-1]+N);
}

int main(){
  int C,R,A,B;
  cin >> N >> K;
  for(int i = 0 ; i < N ; i++){
    cin >> C >> R;
    taxi[i] = pii(C,R);
  }
  for(int i = 0 ; i < K ; i++){
    cin >> A >> B; A--; B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  cout << dijkstra() << endl;
  return 0;
}

Measured memory_bytes: 99800
#include <iostream>
using namespace std;
int main(void){
    int n,a[10000],b,c[500],k=0,i,j;
    for(cin>>n,i=0;i<n;i++)cin>>a[i];
    for(cin>>b,i=0;i<b;i++)cin>>c[i];
    for(i=0;i<b;i++){
        for(j=0;j<n;j++){
            if(c[i]==a[j]){
                k++;
                break;
            }
        }
    }
    cout<<k<<endl;
}

Measured memory_bytes: 3148
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct edge{
  int from, to, cost;
};
edge es[10000];
int G[100][100], hd;
bool use[100][100];


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, m);
    rep(i, n)rep(j, n){
      G[i][j] = 12345123;
      use[i][j] = true;
    }
    hd = 0;
    rep(i, m){
      int3(a, b, c);
      --a; --b;
      G[a][b] = c;
      G[b][a] = c;
      use[a][b] = false;
      use[b][a] = false;
      es[hd++] = (edge){a, b, c};
    }

    rep(k, n)rep(i, n)rep(j, n){
      if(G[i][j] > G[i][k] + G[k][j]){
        G[i][j] = G[i][k] + G[k][j];
      }
    }

    int cnt = 0;
    rep(i, m){
      if(es[i].cost > G[es[i].from][es[i].to]){
        ++cnt;
        //pri2(es[i].from, es[i].to);
      //  pri3(i, es[i].cost, G[es[i].from][es[i].to]);
      }
    }
    //rep(i, n)rep(j, n)pri3(i, j, G[i][j]);

    pri(cnt);

/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,s=1;
    double ans=0;
    cin>>n;
    long long int a[n],c=1,i;
    for(i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0)
            c=0;
        //cout<<log10(a[i])<<endl;
        ans=ans+(log10(a[i]));
        //cout<<ans<<endl;
    }
    if(c==0)
        cout<<"0"<<endl;
    else if(ans<=18){
        for(i=0;i<n;i++)
            s=s*a[i];
        if(s<=1000000000000000000)
        cout<<s<<endl;
        else
            cout<<"-1"<<endl;
    }
    else
        cout<<"-1"<<endl;
    return 0;
}



Measured memory_bytes: 4616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
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;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    ll n,m,ans;
    cin>>n>>m;
    ans=1900*m+100*(n-m);
    ans*=pow(2,m);
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll x;
int power(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res *= a;
    a *= a;
    b >>= 1;
  }
  return res;
}
main() {
  file("lala");
  ios;
  cin >> x;
  fo(len, 1, INF1, 1) {
    if (power(26, len) >= x) {
      --x;
      string ans = "";
      fo(i, 1, len, 1) {
        char d;
        int y;
        for (int j = 0; j < 26; ++j) {
          if (j * power(26, len - i) <= x) {
            d = char(j + 'a');
            y = j;
          }
        }
        x -= y * power(26, len - i);
        ans += d;
      }
      cout << ans;
      return 0;
    }
    x -= power(26, len);
  }
  return 0;
}
/**

*/


Measured memory_bytes: 3592