akhauriyash/Code-Regression huggingface dataset:
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; gi(n);
	ll ans = 0;
	rep1(i, n) if(i % 3 && i % 5) ans += i;
	print(ans);
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std; 

typedef long long ll;

ll calc(ll H) {
    if (H == 1) {
        return 1;
    } else {
        return 2 * calc(H/2) + 1;
    }
}

int main() {

    ll H;
    cin >> H;

    ll res = calc(H);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    vector<int> x(N);
    vector<int> y(M);
    rep(i,N) cin >> x[i];
    rep(i,M) cin >> y[i];
    
    sort(all(x));
    sort(all(y));
    
    int Z = x[N-1]+1;
    
    for (int z = Z; z <= y[0]; z++) {
        if (X < Z && Z <= Y) {
            cout << "No War" << endl;
            return 0;
        }
    }
    
  
    cout << "War" << endl;
    
    
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string S;
  cin>>S;
  set<char> s;
  for(int i=0;i<3;i++)
    s.insert(S.at(i));
  if(s.size()==3)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args : Array<String>) {
    val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
    val cc = Array(h) { readLine()!! }

    val hBitSets = (0L until (1L shl h)).map { BitSet.valueOf(longArrayOf(it)) }
    val wBitSets = (0L until (1L shl w)).map { BitSet.valueOf(longArrayOf(it)) }

    var ans = 0
    hBitSets.forEach { hBits ->
        wBitSets.forEach { wBits ->
            (0 until h).filter { !hBits[it] }.fold(0, { acc, hIdx ->
                acc + (0 until w).filter { !wBits[it] }.count { wIdx -> cc[hIdx][wIdx] == '#' }
            }).let {
                if (it == k) ans++
            }
        }
    }

    println(ans)
}

Measured memory_bytes: 43420
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;

using Graph = vector<vector<int>>;

ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}
ll mul(ll l, ll r) {
    ll ret =1;
    for(int i=0; i<l-r+1; ++i) {
        ret*=i+r;
        ret%=MOD;
    }
    return ret;
}
ll com(ll n, ll k) {
    ll ret1 = mul(n,n-k+1);
    ll ret2 = mul(k,1);
    ll ret3 = modPow(ret2, MOD-2);
    return ret1*ret3%MOD;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k; cin >> n >> k;
    vi A(n); rep(i,n) cin >> A[i];
    sort(all(A),greater<int>());
    int res = 0;
    rep(i,k) {
        res += A[i];
    }
    cout << res << "\n";
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
  int a[5], b[5], c[5];
  int max = 0;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
    b[i] = ((a[i] - 1) / 10) + 1;
    c[i] = (b[i] * 10) - a[i];
    if (c[i] > max) max = c[i];
  }
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    ans += (b[i] * 10);
  }
  ans -= max;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(a: i64, b: i64) -> i64 {
    use std::cmp::min;
//    use std::num::Float;

    if  a == b {
        2*a - 2
    } else if (a-b).abs() == 1 {
        let m = min(a,b);
        2*m - 2
    } else {
        let mut c = ((a*b) as f64).sqrt() as i64;
        if c*c == a*b {
            c -= 1
        }

        if c*(c+1) >= a*b {
            2*c - 2
        } else {
            2*c - 1
        }
    }
}

fn main() {
    let n = parse_line!(u32);
    for _ in 0..n {
        let (a, b) = parse_line!(i64, i64);
        println!("{}", solve(a, b));
    }
}

#[test]
fn solve_test() {
    assert_eq!(solve(1,4), 1);
    assert_eq!(solve(10,5), 12);
    assert_eq!(solve(3,3), 4);
    assert_eq!(solve(4,11), 11);
    assert_eq!(solve(8,9),  14);
    assert_eq!(solve(22, 40), 57);
    assert_eq!(solve(8, 36), 31);
    assert_eq!(solve(314159265, 358979323), 671644785);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  for(int i=0; ;i++){
    if(i%2==0)c-=b;
    else a-=d;
    if(a<=0){cout<<"No"<<endl; break;}
    else if(c<=0){cout<<"Yes"<<endl; break;}
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<sstream>

using namespace std;

int main () {
  	string split;
	getline(cin, split);
	stringstream ss(split);
  
  	while(getline(ss, split, ' ')){
  		putchar(toupper(split[0]));
	}
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,m;
    int i,j,k;
    int mat[100][100]={{}};
    int ve[100]={};
    cin>>n>>m;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>mat[i][j];
        }
    }
    for(j=0;j<m;j++)
    cin>>ve[j];
    for(i=0;i<n;i++){
        int x=0;
    for(j=0;j<m;j++)
    x+=mat[i][j]*ve[j];
    cout<<x<<endl;
    }
    return 0;
     
}


Measured memory_bytes: 3120
#include <stdio.h>

int main() {

  int sum = 0;
  int a,b,c,d,e,f;

  scanf("%d %d %d %d %d %d",&a,&b,&c,&f,&d,&e);
  sum = a + b*5 + c*10+f*50 + d*100+e*500;

  
  //  printf("sum = %d\n",sum);
  if(sum >= 1000) printf("1\n");
  else printf("0\n");

  return 0;

}

Measured memory_bytes: 584
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename M>
void warshallFloyd(M &m, const int &n) {
  rep(k, n) rep(i, n) rep(j, n) cmin(m[i][j], m[i][k] + m[k][j]);
}

void solve() {
  int n;
  while (cin >> n) {
    n = n % 39 + 39 * (n % 39 == 0);
    cout << "3C" << setfill('0') << setw(2) << n << endl;
  }
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main (){
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  if(A1 + A2 + A3 <= 21)
    cout << "win" << endl;
  else
    cout << "bust" << endl;
}
  

Measured memory_bytes: 256
n=int(raw_input())
a=map(int,raw_input().split())
ansr=[]
ansl=[]
if n%2==0:
    for i in xrange(0, n, 2):
        ansr.append(a[i])
    for i in xrange(1, n, 2):
        ansl.append(a[i])
else:
    for i in xrange(0, n, 2):
        ansl.append(a[i])
    for i in xrange(1, n, 2):
        ansr.append(a[i])
ansl.reverse()
print " ".join(map(str,ansl)) +" "+ " ".join(map(str, ansr))


Measured memory_bytes: 62812
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
#define debug(x) cout << x << " :" <<#x << endl  
int main(void) {
    int a, b, c;
    cin >> a >> b >> c;
    bool p = false;
    if(a%b == c) {
        cout << "YES" << endl;
        p=true;
    } else {
        int i = 2*a;
        while(i%b != a%b) {
            if(i%b == c) {
                cout << "YES" << endl;                                                               
                p = true;    
                break;
            }
            i += a;
        }
    }
    if(!p) cout << "NO" << endl;
    
}


Measured memory_bytes: 256
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, D = getlist()
	ans = 0
	for i in range(N):
		X, Y = getlist()
		if X ** 2 + Y ** 2 <= D ** 2:
			ans += 1

	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 68680
A, B, M = map(int, input().split())
aList = list(map(int, input().split()))
bList = list(map(int, input().split()))

minPrice = sorted(aList)[0] + sorted(bList)[0]

for indx in range(M):
    x, y, c = map(int, input().split())
    if minPrice >= (aList[x-1] + bList[y-1] - c):
        minPrice = (aList[x-1] + bList[y-1] - c)

print(minPrice)

Measured memory_bytes: 18736
#include <iostream>
using namespace std;
int main ()
{
	long long a, b, k;
	cin>>a>>b>>k;
	if(k>a){
	k-=a;
	a=0;
	}else{
	a-=k;
	k=0;
	}
	if(k!=0)
	if(k>b){
	b=0;
	}else{
		b-=k;
	}
	cout<<a<<" "<<b;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for (auto &it : t) cout << it << " ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   string s;
   cin >> s;
   vector<string> v = { "Sunny", "Cloudy", "Rainy"};
   if (s == v[0]) cout << v[1];
   else if (s == v[1]) cout << v[2];
   else if (s == v[2]) cout << v[0];	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[105],zs;
int main()
{
	cin>>n>>m;
	for (int i=1;i<=n;i++)
	  cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=n;i>=n-m+1;i--)
	  zs+=a[i];
	cout<<zs<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    int flg=0;

    cin>>a>>b>>c;
    for(int i=a;i<a*b;i+=a){
        if(i%b==c){
            flg=1;
            break;
        }
    }
    if(flg==0){
        cout<<"NO"<<endl;
    }
    else{
        cout<<"YES"<<endl;
    }
}

/*
sum=a*n
nは自然数

sum/b=sum%b/b+(sum/b)の整数


*/

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n;
	cin>>n;
	int T;
	cin>>T;
	vint v(n);
	rep(i,n) cin>>v[i];
	vll w(n,0);
	ll t = v.back();
	ll m = 0;
	for(int i=n-1;i>=0;i--){
		w[i] = t-v[i];
		maxs(t,(ll)v[i]);
		maxs(m,w[i]);
	}
	int ans = 0;
	rep(i,n){
		if(w[i]==m) ans++;
	}
	cout<<ans<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 1408
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int n,d,x[10][10],sum,r,sa,ans=0;
    scanf("%d %d",&n,&d);
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            scanf("%d",&x[i][j]);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum=0;
            for(int k=0;k<d;k++){
                sa=x[i][k]-x[j][k];
                sum+=sa*sa;
            }
            r=sqrt(sum);
            if(r*r==sum){
                ans++;
            }
        }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long
#define pii pair<int,int>
#define pb(x) push_back(x)
#define lbound lower_bound
#define ubound upper_bound
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcountll(x)
#define printv(v) for(auto p : v) cout << p << " ";
#define printa(a,n) for(int i = 0 ; i < n ; i++) cout << a[i] << " "; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


using namespace std;

int divisors[10000001];
int divide(int n)
{
  for(int i = 1; i <= n; i++)
  {
    for(int j = 1; j * i <= n; j++){
      divisors[i*j]++;
    }
  }
  int sum = 0;
  for(int i =1 ; i<=n ; i++){
    sum = sum+(i*divisors[i]);
  } 
  return sum;
} 
int32_t main()
{
   fast;
   #ifndef ONLINE_JUDGE
   freopen("goodluckin.txt","r",stdin);
   freopen("goodluckout.txt","w",stdout);
   #endif
   int n;
   cin >> n;
   int k =divide(n);
   cout << k;

}

Measured memory_bytes: 81744
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    var s = input[0];
       var acgt='ACGT';
      var cnt = 0;cnt2 = 0;
    for(i=0;i<s.length;i++){
      　　var q =s.substr(i,1)
         var result = acgt.indexOf(q);
                if(result >=0){cnt = cnt+1;
                        }
           else if(cnt>cnt2){var cnt2=cnt;var cnt = 0;
                              }
                       else{ var cnt = 0;}
                   }
       
        if(cnt>cnt2){var cnt2=cnt;};      
        console.log(cnt2) ;
   
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val n = sc.nextInt()
    val k = sc.nextInt()

    var l = ArrayList<Int>(n)
    for (i in 0..n-1) {
        l.add(sc.nextInt())
    }
    l.sortDescending()

    println(l.take(k).sum())
}

Measured memory_bytes: 29724
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 998244353;

using namespace std;

int main(){
    string S;
    string pre,su;
    pre = "";
    su = "";
    ll Q;
    bool reverse;

    cin >> S >> Q;

    reverse = false;

    for(int i = 0; i < Q; i++){
        int t, f;
        string c;
        cin >> t;
        if(t == 1){
            reverse = !reverse;
        } else {
            cin >> f >> c;
            if(f == 1){
                if(reverse == false){
                    pre = c + pre;
                } else {
                    su = su + c;
                }
            } else {
                if(reverse == false){
                    su = su + c;
                } else {
                    pre = c + pre;
                }
            }
        }
    }

    if(reverse == false){
        cout << pre << S << su << endl;
    } else {
        ll length = S.size()-1;
        for(int i = length; i >= (length+1)/2; i--){
            char t = S[i];
            S[i] = S[length-i];
            S[length-i] = t;
        }
        length = pre.size()-1;
        for(int i = length; i >= (length+1)/2; i--){
            char t = pre[i];
            pre[i] = pre[length-i];
            pre[length-i] = t;
        }
        length = su.size()-1;
        for(int i = length; i >= (length+1)/2; i--){
            char t = su[i];
            su[i] = su[length-i];
            su[length-i] = t;
        }
        cout << su << S << pre << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <tuple>
#include <utility>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)

void solve()
{
    ll K,S;
    ll ans = 0;
    cin >> K >> S;
    for1(x,min(K+1,S+1)) {
        for1(y,min(K+1,S+1-x)) {
            ll z = S - x - y;
            if (0 <= z && z <= K) {
                ++ans;
            }
        }
    }

    cout << ans << endl;
}

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


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for(auto& i: A) cin >> i;
  for(auto& i: A) i %= M;

  vector<int> sum(N + 1);
  map<int, int> cnt;
  for(auto i = 0; i < N; ++i) ++cnt[sum[i + 1] = (sum[i] + A[i]) % M];

  auto ans = 0ll;
  for(auto i = 1; i <= N; ++i) {
    ans += cnt[sum[i - 1]];
    --cnt[sum[i]];
  }
  cout << ans << endl;
}


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

int check(int baggages[],int baggageAmount, int trackAmount, long maxWeight) {
	int i = 0;
	for (int j = 0; j < trackAmount; j++) {
		int weight = 0;
		while (baggages[i] + weight <= maxWeight) {
			weight += baggages[i];
			i++;
			if (i == baggageAmount) return maxWeight;
		}
	}
	return 0;
}

int main(void) {
	int baggageAmount, trackAmount, tracks[100001],baggages[100001];

	cin >> baggageAmount >> trackAmount;
	for (int i = 0; i < baggageAmount; i++) {
		cin >> baggages[i];
	}

	long long left = 0, right = 100000 * 10000;
	while (right - left > 1) {
		long weight = (left + right) / 2;
		if (check(baggages, baggageAmount, trackAmount, weight) >= weight) {
			right = weight;
		} else {
			left = weight;
		}
	}
	cout << right << endl;
	return 0;
}

Measured memory_bytes: 1548
#include <iostream>
#include <string>
#include <vector>
#include <deque>
using namespace std;

vector<string> v;
int dist[110][110];
bool dtrm[110][110];

int main(void){
    int H, W;
    cin >> H >> W;
    v.resize(H);
    for(int i=0; i<H; ++i){
        cin >> v[i];
    }
    for(int i=0; i<=H; ++i){
        for(int j=0; j<=W; ++j){
            dist[i][j]=1000;
            dtrm[i][j]=false;
        }
    }
    if(v[0][0]=='.') dist[0][0]=0;
    else dist[0][0]=1;
    deque<int> dq{0};
    while(!dtrm[H-1][W-1]){
        int x=dq.front()/W, y=dq.front()%W;
        dq.pop_front();
        if(!dtrm[x][y]){
            dtrm[x][y]=true;
            if(x+1<H && (!dtrm[x+1][y])){
                if(v[x][y]==v[x+1][y]){
                    if(dist[x+1][y]>dist[x][y]){
                        dist[x+1][y]=dist[x][y];
                        dq.emplace_front((x+1)*W+y);
                    }
                }
                else if(dist[x+1][y]>dist[x][y]+1){
                    dist[x+1][y]=dist[x][y]+1;
                    dq.emplace_back((x+1)*W+y);
                }
            }
            if(y+1<W && (!dtrm[x][y+1])){
                if(v[x][y]==v[x][y+1]){
                    if(dist[x][y+1]>dist[x][y]){
                        dist[x][y+1]=dist[x][y];
                        dq.emplace_front(x*W+y+1);
                    }
                }
                else if(dist[x][y+1]>dist[x][y]+1){
                    dist[x][y+1]=dist[x][y]+1;
                    dq.emplace_back(x*W+y+1);
                }
            }
        }
    }
    if(v[H-1][W-1]=='#') ++dist[H-1][W-1];
    cout << dist[H-1][W-1]/2 << endl;
    return 0;
}


Measured memory_bytes: 384
n,m = map(int,input().split())
dp = [-1]*n
for _ in range(m):
    a, b = (int(x) for x in input().split())
    if dp[a-1] == -1 or dp[a-1] == b:
        dp[a-1] = b
    elif a-1 == 0 and b == 0 and n>1:
        print(-1)
        exit()
    else:
        print(-1)
        exit()

if dp[0] == -1 and n>1:
    dp[0]=1
elif dp[0] == -1 and n==1:
    dp[0] = 0

for i in range(n):
    if dp[i] == -1:
        dp[i] = 0

t = ''.join(map(str, dp))
if t[0] == '0' and 1< n:
    print(-1)
    exit()
else:
    print(t)

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


int main()
{
	int N,P;
	cin>>N>>P;
	vector<int> A(N);
	rep(i,N) cin>>A[i];
	sort(A.begin(),A.end(),greater<int>());
	vector<ll> dp(N*100+1,0);
	dp[0]=1;
	for(int a : A)
	{
		for(int x=N*100;x>=a;x--)
		{
			dp[x]+=dp[x-a];
		}
	}
	ll ans=0;
	for(int i=P;i<=N*100;i+=2)
	{
		ans+=(ll)dp[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3672
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <ctype.h>
const int maxn = 5e6 + 100;
char s[maxn];
int main()
{
    scanf("%s",s + 1);
    int n = strlen(s + 1);
    long long t = 0;
    for (int i = 1; i <= n; ++i) t = t + s[i] - 48;
    if(t % 9 == 0) puts("Yes");
    else puts("No");
    return 0;
}

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


int main(){
  int n;
  cin >> n;
  vector<string>data;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    data.push_back(s);
  }
  sort(data.begin(),data.end());
  data.push_back("0");
  int temp=0;
  ll ans=0;
  rep(i,n){
    temp++;
    if(data[i]!=data[i+1]){
      ans += (ll)temp*(temp-1)/2;
      temp=0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5748
#include <iostream>
using namespace std;
 
char S[4];
 
int main(){
  cin >> S;
  if(S[0] == S[1] && S[2] == S[3] && S[0] != S[2]){
    cout << "Yes";
  }
  else if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1]){
    cout << "Yes";
  }
  else if(S[0] == S[3] && S[2] == S[1] && S[0] != S[1]){
    cout << "Yes";
  }
  else{
    cout << "No";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
		public static int length(long n)
		{
			int count=0;
			while(n!=0)
			{
				count++;
				n/=10;
			}
			return count;
		}
		public static void main(String[] args){
			
			Scanner s = new Scanner(System.in);
			long n=s.nextLong();
			int nSum=0;
			int length = length(n);
			int firstDigit = Integer.parseInt(Long.toString(n).substring(0, 1));
			while(n!=0)
			{
				nSum+=n%10;
				n/=10;
			}
			int max = Integer.max(9*(length-1)+firstDigit-1,nSum);
			System.out.println(max);
		}	
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    long long int N, A, B;
    cin >> N >> A >> B;
    cout << ( A > B || ( N == 1 && A != B ) ? 0 : ( B - A ) * ( N - 2 ) + 1 ) << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

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

    vector<vector<int>> testimony(N, vector<int>(N, -1));
    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        for (int j = 0; j < A; j++) {
            int x, y;
            cin >> x >> y;
            testimony[i][x - 1] = y;
        }
    }

    int output = 0;
    for (int i = 0; i < (1 << N); i++) {
        bitset<15> bs(i);
        int honest = 0;
        for (int j = 0; j < N; j++) {
            if (!bs[j]) continue;
            honest++;
            for (int k = 0; k < N; k++) {
                if (testimony[j][k] == 1 && !bs[k]) {
                    honest = -1e9;
                    goto loop_exit;
                }
                if (testimony[j][k] == 0 && bs[k]) {
                    honest = -1e9;
                    goto loop_exit;
                }
            }
        }
    loop_exit:
        if (honest > output) output = honest;
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3608
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

const mod = 1000000007

func mpow(x,n int) int {
	a := 1
	for ;; {
		if n&1 == 1 {
			a = a*x %mod
		}
		x = x*x %mod
		n = n >> 1
		if n == 0 {
			break
		}
	}
	return a
}

func comb(a,b int, fac,facp []int) int {
	if a == 0 && b == 0 {
		return 1
	}
	return (fac[a]*facp[b]%mod)*facp[a-b]%mod
}

func main() {
	sc.Split(bufio.ScanWords)
	
	n,k := scanInt(),scanInt()

	blue := k
	red := n-k

	fac := make([]int,n+1) // n!
	facp := make([]int,n+1) // n!^{mod-2}
	fac[0] = 1
	facp[0] = 1
	for i := 0; i < n; i++ {
		fac[i+1] = fac[i]*(i+1)%mod
		facp[i+1] = facp[i]*mpow(i+1,mod-2) %mod
	}

	for i := 1; i < k+1; i++ {
		if red+1 < i {
			fmt.Println(0)
			continue
		}

		fmt.Println(comb(red+1,i,fac,facp)*comb(blue-1,blue-i,fac,facp)%mod)
	}
}


Measured memory_bytes: 640
from collections import deque
from copy import copy

N, M, Q = map(int, input().split())
X = [tuple(map(int, input().split())) for _ in range(Q)]

queue = deque()
for i in range(1, M+1):
    queue.append([i])
while queue[0] != [1] * N:
    x = queue.popleft()
    for i in range(x[-1], M+1):
        y = copy(x)
        y.append(i)
        queue.append(y)

score_max = 0
for A in queue:
    score = 0
    for a, b, c, d in X:
        if A[b-1] - A[a-1] == c:
            score += d
    score_max = max(score, score_max)

print(score_max)


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/04/27  Problem: ABC 125 A / Link: http://abc125.contest.atcoder.jp/tasks/abc125_a  ----- */


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

	LL A, B, T; cin >> A >> B >> T;
	LL ans = (T/A)*B;
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        while (true)
        {
            string str = Console.ReadLine();
            if (str == "0")
            {
                break;
            }
            int sum = 0;
            foreach (var item in str)
            {
                sum += int.Parse(item.ToString());
            }
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 15964
while True:
    try:
        n=int(input())
        num=list(range(n+1))
        num[1]=0
        for i in range(n):
            if num[i]>n**0.5:
                break
            if num[i]==0:
                continue
            for j in range(num[i]*2,n+1,num[i]):
                num[j]=0
        print(n+1-num.count(0))
    except:
        break


Measured memory_bytes: 56424
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[110];
int vis[110], R[110];
int main() {
	int i, j;
	scanf("%d", &n);
	for (i = 1; i <= n; i++)scanf("%d", &w[i]);
	for (i = 1; i <= n; i++) {
		int cur = 1, pv = -1;
		for (j = 1; j <= n; j++) {
			if (vis[j])cur++;
			else {
				if (w[j] == cur && cur <= i) {
					pv = j;
				}
			}
		}
		if (pv == -1) {
			puts("-1");
			return 0;
		}
		R[i] = w[pv];
		vis[pv] = 1;
	}
	for (i = 1; i <= n; i++)printf("%d\n", R[i]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using pll = pair<long long, long long>;
int N;
long long D, A;
vector<long long> X, H;

long long solve() {
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0);
    sort(ids.begin(), ids.end(), [&](int i, int j) {
            return X[i] < X[j];});

    long long res = 0;
    queue<pll> que;
    long long num = 0;
    for (auto i : ids) {
        while (!que.empty() && que.front().first < X[i]) {
            num -= que.front().second;
            que.pop();
        }
        H[i] -= num;
        if (H[i] <= 0) continue;
        res += H[i];
        que.push({X[i] + D*2, H[i]});
        num += H[i];
    }
    return res;
}

int main() {
    while (cin >> N >> D >> A) {
        X.resize(N); H.resize(N);
        for (int i = 0; i < N; ++i) {
            cin >> X[i] >> H[i];
            H[i] = (H[i] + A - 1) / A;
        }
        cout << solve() << endl;
    }
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n, m;
    cin >> n >> m;

    vector<int> cnt(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        ++cnt[a];
        ++cnt[b];
    }

    bool flag = true;
    rep(i, n){
        flag &= cnt[i] % 2 == 0;
    }

    if(flag){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans = 0;
const ll INF = 1LL << 60; //MAX 9223372036854775807

int main()
{
ll n , k ;
cin >> n >> k ;
vector<ll> a(n);
ll sum=0;
rep(i, n){
  cin >> a[i];
  sum+=a[i];
}
sort(a.rbegin(), a.rend());
vector<int> yaku;
for (int i = 1; i*i <= sum; i++)
{
  if (sum % i == 0)
  {
    yaku.push_back(i);
    if(sum/i!=i)yaku.push_back(sum / i);
  }
}
sort(yaku.rbegin(), yaku.rend());
rep(i,yaku.size()){
  ll h=yaku[i];
  ll eps=0;
  ll count=0;
  vector<ll> aa;
  rep(j,n){
    aa.push_back(a[j]-(a[j]/h)*h);
    eps+=aa[j];
  }
  sort(aa.rbegin(), aa.rend());
  rep(j,eps/h){
    count+=h-aa[j];
  }
  if(count<=k){
    cout << h << endl;
    return 0;
  }
}

return 0;
}


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

int main() {
    int A,B;
    cin >> A >>B;
    if(A <= 5){
        cout << "0" << endl;
    }else if(A <= 12){
        cout << B / 2 << endl;
    }else{
        cout << B << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define NIL -1

static const int MAX = 500;
static const int INFTY = (1<<21);


int main(){
  int n, i, j, e, sum;
  int M[MAX][MAX];
  int u, v, r=0;
  int minv;
  int d[MAX];
  int pi[MAX];
  int vis[MAX];
  int key[MAX];

  scanf("%d", &n);

  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      M[i][j] = (e==-1)?INFTY:e;
    }
  }

  for(u=0; u<n; u++){
    key[u] = INFTY;
    pi[u] = NIL;
    vis[u] = 0;
  }
  key[r] = 0;
  //sum = 0;
  while(1){
    u = NIL;
    minv = INFTY;
    for(i=0;i<n;i++){
      if(key[i] < minv && vis[i] == 0){
	u=i;
	minv=key[i];
      }
    }
    //printf("%d\n",u+1);
    if(u==NIL)break;
    //sum += key[u];
    vis[u] = 1;

    for(v=0; v<n; v++){
      if(M[u][v] < key[v] && vis[v] == 0){
	key[v] = M[u][v];
	pi[v] = u;
      }
    }
  }
  /*for ( i = 0; i < n; i++ ){
   printf("pi = %d\n",1+pi[i]);
   }*/
  sum = 0;
 
  for ( i = 0; i < n; i++ ){
    if ( pi[i] != -1 ) sum += M[i][pi[i]];
    //printf("%d %d\n",sum,M[i][pi[i]]);
  }
  
  printf("%d\n", sum);

  return 0;
}

Measured memory_bytes: 808
import sys
s=input()
l=len(s)
if l%2==1:
  print('No')
  sys.exit()
for i in range(0,l,2):
  if s[i]=='h':
    if s[i+1]!='i':
      print('No')
      sys.exit()
  else:
    print('No')
    sys.exit()
print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int n;cin>>n;
  int m = n;
  int s = 0;
  while (n>0) {
    s += n%10;
    n/=10;
  }
  bool ans = m%s==0;
  cout << (ans?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif

typedef std::pair<int, int> IntPair;


//static void ABC120D_DecayedBridges();
static void ABC117B_Polygon();


#if 1
int main()
{
	//ABC120D_DecayedBridges();
	ABC117B_Polygon();

	fflush(stdout);
	return 0;
}
#endif

static void ABC117B_Polygon()
{
	int N;
	int L[101] = { 0 };

	scanf(" %d", &N);
	for (int i = 0; i < N; i++) {
		scanf(" %d", &L[i]);
	}

	std::sort(L, L + N, std::greater<int>());

	const char* ans = "No";

	int sum = 0;
	for (int i = 1; i < N; i++) {
		sum += L[i];
	}
	if (L[0] < sum) {
		ans = "Yes";
	}

	printf("%s\n", ans);
}


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

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

		int[] inputSequences = new int[stdIn.nextInt()];
		IntStream.range(0, inputSequences.length).forEach(i -> inputSequences[i] = stdIn.nextInt());

		int[] checkSequences = new int[stdIn.nextInt()];
		IntStream.range(0, checkSequences.length).forEach(i -> checkSequences[i] = stdIn.nextInt());

		int cnt = 0;
		for (int checkNum : checkSequences) {
			int searchIndex = Arrays.binarySearch(inputSequences, checkNum);

			if(searchIndex > 0) {
				cnt++;
			}
		}

		System.out.println(cnt);

		stdIn.close();
	}
}



Measured memory_bytes: 85120
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
//map<key,value>

int main(){
  int n,ans=0;
  cin >> n;
  int h[n];
  for(int i=0;i<n;i++)cin >> h[i];
  for(int i=0;i<n;i++){
    int c=0;
    for(int j=0;j<i;j++){
      if(h[j]>h[i])goto gh;
    }
    ans++;
    gh:;
  }
  cout << ans;
}


Measured memory_bytes: 256
var
	a:array[0..200] of longint;
	i,j,t,n,ans:longint;
begin
	read(n,ans);
	for i:=1 to n do read(a[i]);
	for i:=1 to n-1 do
		for j:=1 to n-i do
			if a[j]>a[j+1] then
			begin
				t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t;
			end;
	i:=1;
	while (ans>=a[i]) and (i<=n) do
	begin
		ans:=ans-a[i];
		inc(i);
	end;
	if (i=n+1) and (ans>0) then dec(i);
	writeln(i-1);
end.

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

#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;

typedef long long ll;


int N;
int X;
int x[100000];

int gcd(int a, int b){
    if(a < b) gcd(b, a);
    int r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}


int main(){
    cin >> N >> X;
    for (int i = 0; i < N; i++){
        cin >> x[i];
    }
    for (int i = 0; i < N; i++){
        if (x[i] - X > 0){
            x[i] = x[i] - X;
        } else {
            x[i] = X - x[i];
        }
    }
    int g = x[0];
    for (int i = 1; i < N; i++){
        g = gcd(g, x[i]);
    }
    cout << g << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cmath>
#include <iomanip>
using namespace std;
 
#define f first
#define s second
 
#define pb push_back
#define pp pop_back
#define mp make_pair
 
#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))
 
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)
 
#define nl '\n'
#define ioi exit(0);
 
 
#define PI 3.14159265
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
//const int mod = 1000000007;
const ll linf = (ll)1e18 + 7;
const ll limit = 2e9;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};
 
//const int mod = 998244353;
 
struct dsu{
	int parent[N];
	int cont;
	void make_set(int n){
		for(int i = 1; i <= n; i++)
			parent[i] = i;
		cont = n;
	}
	
	int find_set(int v){
		if(v == parent[v])
			return v;
		return find_set(parent[v]);
	}
	
	void union_sets(int a, int b){
		a = find_set(a);
		b = find_set(b);	
		if(a != b){
			parent[b] = a;
			cont--;
		}
	}	
};


struct nod{
	string s;
	int n;
	nod(string s_, int n_){
		s = s_;
		n = n_;
	}
};

bool operator<(const nod& a, const nod& b)
{
	if(a.n != b.n)
		return a.n < b.n;
	else{
		int k1 = (int)a.s.size();
		int k2 = (int)b.s.size();
		for(int i = 0; i < min(k1,k2); i++){
			if(a.s[i] == b.s[i])
				continue;
			if(a.s[i] < b.s[i])
				return true;
			else
				return false;
			
		}
		if(k1 <= k2)
			return true;
		return false;
	}
	
}

int main(){
	vector<nod> v;
	set<string> st;
	map<string, int> tab;
	int n; cin>> n;
	string s;
	for(int i = 0; i <n; i++){
		cin>> s;
		st.insert(s);
		tab[s] += 1;
	}
	for(string x: st){
		v.push_back(nod(x,tab[x]));
	}
	
	
	sort(v.begin(),v.end());
	
	int maxi = 0;
	for(nod x: v){
		maxi = max(maxi, x.n);
		//~ cout<<x.s<<" "<<x.n<<endl;
	}
	
	for(nod x: v){
		if(x.n == maxi)
			cout<< x.s<<" ";
	}
	
	return 0;
}













Measured memory_bytes: 38772
N = input()
K = int(input())

if len(N) < K:
  print(0)
  exit()

keta = []
for k in range(len(N)):
  keta.append(int(N[-k-1]))
ans = [1, keta[0], 0, 0];

def combination(N,K):
  if N < K:
    return 0
  else:
    p = 1
    for k in range(K):
      p *= N
      N -= 1
    for k in range(1, K+1):
      p //= k
    return p
for k in range(1, len(N)-1):
  if keta[k] > 0:
    a = [1, 0, 0, 0]
    for j in range(1, 4):
      a[j] += (9**(j))*combination(k, j)
      a[j] += (keta[k]-1)*combination(k, j-1)*(9**(j-1)) + ans[j-1]
    ans = [] + a
answer = (9**(K))*combination(len(N)-1, K)
answer += (keta[-1]-1)*(9**(K-1))*combination(len(N)-1, K-1)
answer += ans[K-1]
print(answer)

Measured memory_bytes: 9076
#pragma GCC optimize("O3")
 #pragma GCC optimize("unroll-loops")
 #pragma GCC optimize("fast-math")
#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int N = 1e5 + 5;

int dp[N][4];

signed main() {
    accell();
    int n;
    cin >> n;
    vector<int>a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    stack<pair<int, int> > st;
    int cur = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (st.empty()) {
            st.push({a[i], i});
            cur += a[i];
            ans += cur;
            continue;
        }
        int lst = i;
        while (st.size() > 0 && a[i] <= st.top().F) {
            cur -= st.top().F * (lst - st.top().S);
            lst = st.top().S;
            st.pop();
        }
        st.push({a[i], lst});
        cur += (i - lst + 1) * a[i];
        ans += cur;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 5120
n=int(input())
a=list(map(int,input().split()))
a.sort()
plus,minus=[],[]
for i in range(n):
    if a[i]>=0:
        plus.append(a[i])
    else:
        minus.append(a[i])
order=[]
if plus and minus:
    if len(plus)>=2:
        for num in plus[:-1]:
            order.append((minus[0],num))
            minus[0]-=num
    for num in minus:
        order.append((plus[-1],num))
        plus[-1]-=num
    print(plus[-1])
else:
    if minus:
        a=a[::-1]
    for i in range(1,n-1):
        order.append((a[0],a[i]))
        a[0]-=a[i]
    if minus:
        a=a[::-1]
    order.append((a[-1],a[0]))
    a[-1]-=a[0]
    print(a[-1])
for x,y in order:
    print(x,y)

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

int main() {
  int N; cin >> N;
  vector<double> p(N);
  for (int i = 0; i < N; i++) cin >> p.at(i);
  // dp[i][j] := i 枚目まで投げて表が j 回出る確率
  vector<vector<double>> dp(N+1, vector<double>(N+1, 0));
  dp.at(0).at(0) = 1.0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i < j) continue;
      // 表
      dp.at(i+1).at(j+1) += dp.at(i).at(j) * p.at(i);
      // 裏
      dp.at(i+1).at(j) += dp.at(i).at(j) * (1.0 - p.at(i));
    }
  }
  double ans = 0;
  for (int j = 0; j <= N; j++) {
    if (j >= (N+1) / 2) ans += dp.at(N).at(j);
  }
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

Measured memory_bytes: 70784