akhauriyash/Code-Regression huggingface dataset:
dice1_ = [int(i) for i in input().split()]
dice1 = {
	(0,0,0):100000,
    (0,0,1):dice1_[0],
    (0,-1,0):dice1_[1],
    (1,0,0):dice1_[2],
    (-1,0,0):dice1_[3],
    (0,1,0):dice1_[4],
    (0,0,-1):dice1_[5]
}
rdice1 = {
    dice1_[0]:(0,0,1),
    dice1_[1]:(0,-1,0),
    dice1_[2]:(1,0,0),
    dice1_[3]:(-1,0,0),
    dice1_[4]:(0,1,0),
    dice1_[5]:(0,0,-1)
}

dice2_ = [int(i) for i in input().split()]
dice2 = {
	(0,0,0):100000,
    (0,0,1):dice2_[0],
    (0,-1,0):dice2_[1],
    (1,0,0):dice2_[2],
    (-1,0,0):dice2_[3],
    (0,1,0):dice2_[4],
    (0,0,-1):dice2_[5]
}
rdice2 = {
    dice2_[0]:(0,0,1),
    dice2_[1]:(0,-1,0),
    dice2_[2]:(1,0,0),
    dice2_[3]:(-1,0,0),
    dice2_[4]:(0,1,0),
    dice2_[5]:(0,0,-1)
}

c = [[dice1_[0],i] for i in dice1_[1:]] + [[dice1_[1],i] for i in dice1_[2:]] + [[dice1_[2],i] for i in dice1_[3:]] + [[dice1_[3],i] for i in dice1_[4:]] +[[dice1_[4],i] for i in dice1_[5:]] + [[dice1_[5],i] for i in dice1_[6:]]
def cross(a,b):
	return(a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])
istrue = sum([1 - int(i) for i in [dice1[cross(rdice1[a],rdice1[b])] == dice2[cross(rdice2[a],rdice2[b])] for a,b in c]])
if istrue == 0:
	print("Yes")
else:
	print("No")



Measured memory_bytes: 5636
import math

N,K = map(int,input().split())
A = list(map(int,input().split()))

def cost(d,numList):
    r = [x%d for x in numList]
    r.sort(reverse=True)
    p = sum(r)//d
    c = 0
    for i in range(p):
        c += d - r[i]
    return(c)

def divisors(n):
    sq = math.ceil(math.sqrt(n))
    ans = []
    for i in range(1,sq):
        if n%i == 0:
            ans.append(i)
            ans.append(n//i)
    return(ans)

divs = divisors(sum(A))
ans = 1
for d in divs:
    c = cost(d, A)
    if c <= K:
        ans = max(ans,d)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
using namespace std;
int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}


Measured memory_bytes: 2564
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const ll INF = 10e16;
const int maxN = 100010;
const int maxD = 15;
const int maxH = 1010; 
const int MOD = 1000000007;

int a[maxN];

int main()
{
	int n;
	scanf("%d",&n);
	int ans = 0;
	for(int i=1;i<=n;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		ans += (r-l+1);
	}
	printf("%d\n",ans);
	return 0;
}  

Measured memory_bytes: 256
import java.io.*;
 
// main
 
public class Main {
  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line;
 
    while ((line = br.readLine()) != null) {
      String[] nums = line.split(" ");
      int a = Integer.parseInt(nums[0]);
      int b = Integer.parseInt(nums[1]);
      int small;
      int big;
      
      if(a >= b) {
    	  big = a;
    	  small = b;
      }else {
    	  big = b;
    	  small = a;
      }
      
	  while(true) {
		 if(big%small == 0) {
			 System.out.println(small);
			 break;			  
		    		  }
		 int tmp = small;
		 small = big%small;
		 big = tmp;
		  
	  }
     
    }
  }
}


Measured memory_bytes: 24216
from bisect import bisect_right,bisect_left
N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-1):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        indU = bisect_left(L,a+b)
        indL = bisect_right(L,b-a)
        if j<indU and i>= indL:
            cnt += indU-indL-2
        elif indL<=i<indU and j>=indU or i<indL and indL<=j<indU:
            cnt += indU-indL-1
        elif j<indL or i>=indU:
            cnt += indU-indL
print(cnt//3)

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

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;


void solve() {
	int n,d;
	cin >> n >> d;

	int cnt = 0;

	F0R(i,n) {
		int x,y;
		cin >> x >> y;

		if((x*x + y*y) <= d*d) cnt++;
	}
	cout << cnt;
}


int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



Measured memory_bytes: 3792
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    string S;
    cin >> S;
    int N;
    N = S.length();
    bool answer = true;
    for (int i = 0; i < (N-1)/2; i++)
    {
        if (S[i]==S[N-1-i]){

        }else{
            answer = false;
            break;
        }
    }
    for (int i = 0; i< ((N-1)/2)/2; i++ ){
        if (S[i]==S[(N-1)/2-1-i]){

        }else{
            answer = false;
            break;
        }
    }
    if (answer == true)
    {
        cout << "Yes";
    }else{
        cout <<"No";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
 
using namespace std;
typedef long long ll;
 
struct UnionFind {
  vector<int> par;
 
  UnionFind(int n) : par(n, -1) { }
  void init(int n) { par.assign(n, -1); }
 
  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
 
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
 
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
 
  int size(int x) {
    return -par[root(x)];
  }
};
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N,M;
  cin>>N>>M;
  
  UnionFind uf(N);
  for(int i=0;i<M;i++){
    int x,y,z;
    cin>>x>>y>>z;
    x--;y--;
    uf.merge(x,y);
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(i==uf.root(i)){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main() {
	int n, m, l;
          long A[100][100] = { 0 }, B[100][100] = { 0 }, C[100][100] = { 0 }, i, j, k;
	cin >> n >> m >> l;
	for (i = 0; i<n; i++){
		for (j = 0; j<m; j++)
			cin >> A[i][j];
	}
	for (i = 0; i<m; i++){
		for (j = 0; j<l; j++)
			cin >> B[i][j];
	}
	for (i = 0; i<n; i++){
		for (j = 0; j<l; j++) {
			for (k = 0; k<m; k++)
				C[i][j] += A[i][k] * B[k][j];
		}
	}
	for (i = 0; i<n; i++){
		for (j = 0; j<l; j++) {
			if (j< l - 1) cout << C[i][j] << " ";
			else cout << C[i][j] << endl;
		}
	}
}

Measured memory_bytes: 1404
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	int n, m;
	cin >> n >> m;
	cout << (n+m)%24;
}


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

int main() {
    int N;
    cin >> N;
    vector<int>v(N);
    set<int>s;
    int count = 0; 
    rep(i, 0, N) cin >> v[i];
    rep(i, 0, N){
        if(v[i] >= 3200) count++;
        else s.insert(v[i]/400);
    }
    if(s.size() == 0){
        cout << "1" << " " << count << endl;
    }else{
        cout << s.size() << " " << s.size() + count << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
//#include <sstream>
//#include <fstream>

using namespace std;

string add (string a, string b )
{
	reverse (a.begin(), a.end() );
	reverse (b.begin(), b.end() );

	while (a.length() != b.length() ){
		if (a.length() > b.length() ){
			b += '0';
		}else if (a.length() < b.length() ){
			a += '0';
		} // end if
	} // end while

	string res = "";
	int carry = 0;

	for (int i = 0; i < a.length(); ++i){
		int an = a[i] - '0';
		int bn = b[i] - '0';
		if (carry == 1 ){
			++an;
		} // end if
		if (an + bn >= 10 ){
			carry = 1;
		}else{
			carry = 0;
		} // end if
		res += ((an + bn ) % 10 ) + '0';
	} // end for

	if (carry == 1 ){
		res += carry + '0';
	} // end if

	reverse (res.begin(), res.end() );

	return res;
}

int main()
{
//	cut here before submit 
//	freopen("testcase.secret", "r", stdin);
	string str = "";
	string res = "0";

	while (getline (cin, str ) ){
		int len = str.length();
		string num = "";

		for (int i = 0; i < len; ++i){
			if (isdigit(str[i]) ){
				num += str[i];
			}else if (!num.empty() ){
				res = add (res, num );
				num = "";
			} // end if
		} // end for
		if (!num.empty() ){
			res = add (res, num );
		} // end if
	} // end loop

	cout << res << endl;	
		
	return 0;
}

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

using namespace std;
int n;
long long f[403][403],a[403],sum[403];

long long S(int l,int r)
{
    return (sum[r]-sum[l-1]);
}

void DP()
{
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=n;++j)
        {
            f[i][j]=1e18;
        }
    }
    for(int i=1;i<=n;++i)
    {
        f[i][i]=0;
    }
    for(int l=n-1;l>=1;--l)
    {
        for(int r=l+1;r<=n;++r)
        {
            for(int k=l;k<=r;++k)
            {
                f[l][r]=min(f[l][r],S(l,k)+S(k+1,r)+f[l][k]+f[k+1][r]);
            }
        }
    }
    printf("%lld\n",f[1][n]);
}

int main()
{
    scanf("%d",&n);
    sum[0]=0;
    for(int i=1;i<=n;++i)
    {
        scanf("%lld",&a[i]);
        sum[i]=sum[i-1]+a[i];
    }
    DP();
    return 0;
}


Measured memory_bytes: 1536
x, y = map(int, input().split())
a = {1,3,5,7,8,10,12}
b = {4,6,9,11}
c = {2}
if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using ll = long long;

int which(char c) {
	if (c == 'r') {
		return 2;
	}
	if (c == 's') {
		return 0;
	}
	if (c == 'p') {
		return 1;
	}
	exit(1);
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> s(3);
	cin >> s[0] >> s[1] >> s[2];
	string t;
	cin >> t;
	ll res = 0;
	for (int i = 0; i < n; ++i) {
		if (i < k || t[i] != t[i - k]) {
			res += s[which(t[i])];
		} else {
			t[i] = 'o';
		}
	}
	cout << res << "\n";
	return 0;
}


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

int main() 
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i=1; i<n; i++) cin >> a.at(i);
	for (int i=1; i<n; i++) b.at(a.at(i) - 1)++;
	for (int i : b) cout << i << endl;

	return 0;
}

Measured memory_bytes: 4840
#include <iostream>

using std::cout;
using std::endl;
using std::cin;


int main()
{
	int A;

	cin >> A;

	cout << "Christmas";
	char eve[] = " Eve";

	switch (A) {
		case 22:
			cout << eve;
		case 23:
			cout << eve;
		case 24:
			cout << eve;
	}

	cout << endl;

	return 0;
}

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

from itertools import permutations

L = list((range(1, N+1)))

M = sorted(list(permutations(L, N)))

len_m = len(M)

a = -1
b = -1

for i in range(len_m):
  pSame = True
  qSame = True
  for j in range(N):
    if M[i][j] != P[j]:
      pSame = False
    if M[i][j] != Q[j]:
      qSame = False
  
  if pSame:
    a = i
  if qSame:
    b = i
    
print(abs(a-b))

Measured memory_bytes: 8308
#!/usr/bin/perl

use strict;
use warnings;

my ($n, $k);
{
    my $in = <STDIN>;
    ($n, $k) = split(" ", $in);
}
my ($r, $s, $p);
{
    my $in = <STDIN>;
    ($r, $s, $p) = split(" ", $in);
}
my $t = <STDIN>;

my @c;
for (my $i=0; $i<$n; $i++) {
    if ("r" eq substr($t, $i, 1)) {
        $c[$i] = 1;
    } elsif ("s" eq substr($t, $i, 1)) {
        $c[$i] = 2;
    } else {
        $c[$i] = 3;
    }
}
for (my $i=0; $i<$n-$k; $i++) {
    if ($c[$i] == $c[$i+$k]) {
        $c[$i+$k] = 0;
    }
}
my $sum;
for (my $i=0; $i<$n; $i++) {
    if ($c[$i] == 1) {
        $sum += $p;
    } elsif ($c[$i] == 2) {
        $sum += $r;
    } elsif ($c[$i] == 3) {
        $sum += $s;
    }
}
print "$sum\n";

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

long long a[100005];
int main(void)
{
    long long n,b,sum=0;
    scanf("%lld" ,&n);
    for(int i=0;i<n+1;i++)
        scanf("%lld" ,&a[i]);
    for(int i=0;i<n;i++)
    {
        scanf("%lld" ,&b);
        long long t = min(b,a[i]);
        sum += t;
        b -= t;
        a[i]-= t;
        long long t2 = min(b,a[i+1]);
        sum += t2;
        b -= t2;
        a[i+1]-= t2;
    }
    printf("%lld" ,sum);
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define maxn (1<<26)+1
#define maxm (int)2e5+2
int dp[maxn];
char s[maxm];
#define INF 0x7f7f7f
int main()
{
	scanf("%s",s);
	int n=strlen(s);
	memset(dp,INF,sizeof(dp));
	long long now=0;
	dp[now]=0;
	for (int i=0;i<n;i++)
	{
		now^=(1<<(s[i]-'a'));
		for (int j=0;j<=25;j++)
		  if ((now^(1<<j))!=now) dp[now]=min(dp[now],dp[now^(1<<j)]+1);
	}
	if (now==0) dp[now]=1;
	printf("%d\n",dp[now]);
}

Measured memory_bytes: 262656
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

const int N = 2e5 + 5, MOD = 2019;

namespace ModFunctions {
	inline int add(int a, int b) {
		a += b;
		if (a >= MOD) {
			a -= MOD;
		}
        return a;
	}

	inline int sub(int a, int b) {
		a -= b;
		if (a < 0) {
			a += MOD;
		}
        return a;
	}

	inline int mul(int a, int b) {
		return int((1ll * a * b) % MOD);
	}

	inline int power(int a, int b) {
		int res = 1;
		while (b > 0) {
			if (b & 1) {
				res = mul(res, a);
			}
			a = mul(a, a);
			b >>= 1;
		}
		return res;
	}

	inline int inv(int a) {
		a %= MOD;
		if (a < 0) {
			a += MOD;
		}
		int b = MOD, u = 0, v = 1;
		while (a) {
			int t = b / a;
			b -= t * a;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		assert(b == 1);
		if (u < 0) {
			u += MOD;
		}
		return u;
	}
}

using namespace ModFunctions;

int suf[N];

void test() {
    string s;
    cin >> s;
    int n = s.size();
    s = 'x' + s;
    map<int, int> cnt;
    for (int i = n, j = 0; i > 0; --i, ++j) {
        suf[i] = add(suf[i + 1], mul(power(10, j), (s[i] - '0')));
        ++cnt[suf[i]];
    }
    long long ans = 0;
    for (int i = n, k = 0; i > 0; --i, ++k) {
        int cur = suf[i + 1];
        ans += cnt[cur];
        --cnt[suf[i]];
    }
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin >> t;
    for (int i = 0; i < t; ++i) {
        test();
    }
    return 0;
}


Measured memory_bytes: 4528
using System;
using System.Collections.Generic;

namespace contest
{
    class Program
    {
        static void Main(string[] args)
        {
            // 文字列の入力
            string[] inputKN = Console.ReadLine().Split(' ');
            int N = int.Parse(inputKN[0]);
            int K = int.Parse(inputKN[1]);

            string[] inputP = Console.ReadLine().Split(' ');
            int[] p = new int[N];
            for (int i=0; i<N; i++)
            {
                int.TryParse(inputP[i], out int num);
                p[i] = num;
            }

            var list = new List<int>();

            // listに要素を追加
            list.AddRange(p);

            // listをソート
            list.Sort();

            int sum = 0;
            for (int i = 0; i < K; i++)
            {
                sum += list[i];
            }

            //出力
            Console.WriteLine(sum);
        }

    }
}


Measured memory_bytes: 28184
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>

#define INF 1000000000
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

using namespace std;

int main() {
  long long N;
  scanf("%lld", &N);
  if (N%2==0) {
    printf("%lld\n", N);
  } else {
    printf("%lld\n", N*2);
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int h, w;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> h >> w;
    int  ba = h / 2;
    long long ans = 0;
    if (w == 1 || h == 1) {
        ans = 1;
    }
    else {
        ans = ba * 1LL * w;
        if (h % 2) ans += (w + 1) / 2;
    }
    cout << ans << E;
    //system("pause");
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    k--;
    if (s[k] == 'A')
        s[k] = 'a';
    if (s[k] == 'B')
        s[k] = 'b';
    if (s[k] == 'C')
        s[k] = 'c';
    cout << s << endl;
}


Measured memory_bytes: 256
//                          VIVEK UPADHYAY
//                         MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                         TAB -TAK CHODEGA NHI :D
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<endl
#define ok cout<<"ok\n" ;
typedef long long ll;
const int MAXN = 45000 + 10 ;
const int MAX = 1e7 ;
double pi = 3.1415926535897932384626433832795;
const ll inf=1e18 ;
int main() {
    
    set<string> s ;
    int N ;
    cin >> N ;
    
    string prev="$" ;
    bool flag = true ;
    for(int i=1;i<=N;i++){
        string str ;
        cin >> str ;
        if(prev=="$") s.insert(str) ;
        else {
            if(s.find(str)!=s.end())flag=false ;
            else if(prev[prev.length()-1]!=str[0])flag=false;
        
        }
        s.insert(str);
        prev=str ;
    }
    if(flag){
        cout<<"Yes\n" ;
    }
    else cout<<"No\n" ;
    return 0 ;
}


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

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

    ll a=1;
    ll b=1;
    ll c=1;
    rep(i, n) {
        a *= 10;
        a %= LARGE;
        b *= 8;
        b %= LARGE;
        c *= 9;
        c %= LARGE;
    }

    ll s = a+b - 2 * c;
    if (s < 0)  s+= LARGE;
    if (s < 0)  s+= LARGE;

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


Measured memory_bytes: 3592
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

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

func isPrime(n int) bool {
	if n == 2 {
		return true
	}

	if n%2 == 0 {
		return false
	}

	for i := 3; i*i <= n; i += 2 {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	x, _ := strconv.Atoi(input())
	for true {
		if isPrime(x) {
			fmt.Println(x)
			break
		}
		x++
	}
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	char s[110];
	long int n;
	long int count=0;
  	long int tmp;
	int i=0,j;
	int pre=0;
	int a=1,b=1;
	scanf("%s",&s);
	scanf("%ld",&n);
	
	i=0; //iはs[]の個数を表す
	while(s[i]!=0){
		i++;
	}
	if(s[0]!=s[i-1]){
		pre=1;
	}
	//all same moji
	j=0;
	while(s[j+1]!=0){
	if(s[j]==s[j+1]){
      tmp=1;
      j++;
    }else{
      tmp=0;
      break;
    }
  }
    if(tmp==1){
    	pre=2;
	tmp=(i*n)/2;
		count=tmp;
    }
	
	if(pre==1){
		count=0;
		//先頭と最後が違う文字
		j=0;
		while(s[j+1]!=0&&s[j]!=0){
		if(s[j]==s[j+1]){
			count++;
			j=j+2;
		}else{
			j++;
		}
	}

	count=count*n;
	}

	if(pre==0){
		//先頭の文字の連続をa 最後の文字の連続をb
		while(s[0]==s[a]){
			a++;
		}
		while(s[0]==s[(i-1)-b]){
			b++;
		}
		j=a;
		while(j!=(i-b)){
		if(s[j]==s[j+1]){
			count++;
			j=j+2;
		}else{
			j++;
		}
	}
	count=count*n;
	count=count+((a+b)/2)*(n-1)+(a/2)+(b/2);
	}
	printf("%ld \n",count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<math.h>
#include <climits>

using namespace std;

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

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

class Dice{
    public:
    int a[7];//-,up,flont,right,left,back,down
    void roll(char d);
    void rotate(void);
};

void Dice::rotate(void){
    int tmp;
    tmp=a[2];
    a[2]=a[3];
    a[3]=a[5];
    a[5]=a[4];
    a[4]=tmp;
}

void Dice::roll(char d){
    int tmp;
    if(d=='N'){
        tmp=a[1];
        a[1]=a[2];
        a[2]=a[6];
        a[6]=a[5];
        a[5]=tmp;
    }
    else if(d=='S'){
        tmp=a[1];
        a[1]=a[5];
        a[5]=a[6];
        a[6]=a[2];
        a[2]=tmp;
    }
    else if(d=='W'){
        tmp=a[1];
        a[1]=a[3];
        a[3]=a[6];
        a[6]=a[4];
        a[4]=tmp;
    }
    else if(d=='E'){
        tmp=a[1];
        a[1]=a[4];
        a[4]=a[6];
        a[6]=a[3];
        a[3]=tmp;
    }
}

int main(void){
    int i;
    int c[6]={};
    Dice dice[2];
    int t;
    int cnt;
    bool b;
    
    for(i=1;i<7;i++){
        std::cin>>dice[0].a[i];
        c[i-1]=dice[0].a[i];
    }
    for(i=1;i<7;i++){
        std::cin>>dice[1].a[i];
        b=0;
        for(int j=0;j<6;j++){
            if(c[j]==dice[1].a[i])b=true;
        }
        if(b){
            continue;
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
        
    }
    
    int j,k;
    char d[7]="NWWWNN"; //NWWWN
    b=0;
    
    for(j=0;j<6;j++){
        for(k=0;k<4;k++){
            b=1;
            for(i=1;i<7;i++){
                if(dice[0].a[i]!=dice[1].a[i]){
                    b=0;
                }
            }
            if(b){
                cout<<"Yes"<<endl;
                return 0;
            }
            dice[0].rotate();
        }
        dice[0].roll(d[j]);
    }
    
    cout<<"No"<<endl;
    return 0;
}



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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

void solve();

int main(void){
    int N, M; cin >> N >> M;
    int A[N][M];
    rep(i, N){
        rep(j, M){
            int temp; cin >> temp; temp--;
            A[i][j] = temp;
        }
    }
    int idx[N] = {};
    vector<int> player[M];
    rep(i, N){
        player[A[i][0]].push_back(i);
    }

    /*
    rep(i, M){
        cout << i << ": ";
        rep(j, player[i].size()){
            cout << player[i][j] << " ";
        }
        cout << endl;
    }
    */


    //一番多いのを消して、その人たちのindexを次に進める
    int ans = 0;
    int del[M] = {};

    rep(i, M){
        if(player[i].size() > ans) ans = player[i].size();
    }
    for(int i = 0; i < M-1; i++){
        //一番多い競技はどれか
        int max_player = -1;
        int eval = 0;
        rep(j, M){
            if(player[j].size() > eval){
                eval = player[j].size();
                max_player = j;
            }
        }
        //cout << max_player << endl;
        rep(j, player[max_player].size()){
            int mv = player[max_player][j]; //動かす対象となる人
            idx[mv]++;
            while(del[A[mv][idx[mv]]] == 1) idx[mv]++;
            player[A[mv][idx[mv]]].push_back(mv);
        }

        player[max_player].clear(); //競技を消す
        del[max_player] = 1;
        //rep(j, M) cout << del[j]; cout << endl;

        //temp: 消した後の競技の中で、最大の人数の集まる競技の人数
        int temp = 0;
        rep(j, M){
            if(player[j].size() > temp) temp = player[j].size();
        }
        if(temp < ans) ans = temp;
    }
    cout << ans << endl;
    return 0;
}

void solve(){}

Measured memory_bytes: 1152
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int X;
	cin >> X;

	int g = gcd(X, 360);

	co(360 / g);
	




	Would you please return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstring>
using namespace std;
const int MAXLEN=100;
char s[MAXLEN+1];
char l[MAXLEN/2+1];
char r[MAXLEN/2+1];

int main(){
	cin>>s;
	int len=strlen(s);
	
	//len是偶数，len是6的话，l=0,1,2,  r=5,4,3 
	//len是奇数，len是7的话，l=0,1,2,  r=6,5,4 
	for(int i=0;i<len/2;i++) l[i]=s[i];
	
	int rbegin;
	if(len%2==0) rbegin=len/2;
	else rbegin=len/2+1;
	for(int j=len-1,i=0;j>=rbegin;j--,i++) r[i]=s[j];

	int ans=0;
	for(int i=0;i<len/2;i++){
		if(l[i]!=r[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

const int N=1e5+5;
const int inf=numeric_limits<int>::max();
ll n,a,b,chebyshev,deg;
bool reachable[N];
map<ll,vector<ll>> c1,c2;
map<ll,set<pair<ll,ll>>> mpx,mpy;
vector<pair<ll,ll>> p;

void dfs(int v){
	reachable[v]=true;
	ll x=p[v].first;
	ll y=p[v].second;
	while(true){
		auto it=mpx[x-chebyshev].lower_bound(make_pair(y-chebyshev,-1));
		if(it==mpx[x-chebyshev].end()||it->first>y+chebyshev) break;
		int u=it->second;
		mpx[x-chebyshev].erase(it);
		if(!reachable[u]) dfs(u);
	}
	while(true){
		auto it=mpx[x+chebyshev].lower_bound(make_pair(y-chebyshev,-1));
		if(it==mpx[x+chebyshev].end()||it->first>y+chebyshev) break;
		int u=it->second;
		mpx[x+chebyshev].erase(it);
		if(!reachable[u]) dfs(u);
	}
	while(true){
		auto it=mpy[y-chebyshev].lower_bound(make_pair(x-chebyshev,-1));
		if(it==mpy[y-chebyshev].end()||it->first>x+chebyshev) break;
		int u=it->second;
		mpy[y-chebyshev].erase(it);
		if(!reachable[u]) dfs(u);
	}
	while(true){
		auto it=mpy[y+chebyshev].lower_bound(make_pair(x-chebyshev,-1));
		if(it==mpy[y+chebyshev].end()||it->first>x+chebyshev) break;
		int u=it->second;
		mpy[y+chebyshev].erase(it);
		if(!reachable[u]) dfs(u);
	}
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>a>>b;
	--a,--b;
	for(int i=0;i<n;++i){
		ll x,y;
		cin>>x>>y;
		c1[x+y].push_back(x-y);
		c2[x-y].push_back(x+y);
		mpx[x+y].insert(make_pair(x-y,i));
		mpy[x-y].insert(make_pair(x+y,i));
		p.emplace_back(x+y,x-y);
	}
	chebyshev=max(abs(p[a].first-p[b].first),abs(p[a].second-p[b].second));
	dfs(a);
	for(auto it:c1)
		sort(c1[it.first].begin(),c1[it.first].end());
	for(auto it:c2)
		sort(c2[it.first].begin(),c2[it.first].end());
	for(int i=0;i<n;++i){
		if(!reachable[i]) continue;
		ll x=p[i].first;
		ll y=p[i].second;
		deg+=upper_bound(c1[x-chebyshev].begin(),c1[x-chebyshev].end(),y+chebyshev)-lower_bound(c1[x-chebyshev].begin(),c1[x-chebyshev].end(),y-chebyshev);
		deg+=upper_bound(c1[x+chebyshev].begin(),c1[x+chebyshev].end(),y+chebyshev)-lower_bound(c1[x+chebyshev].begin(),c1[x+chebyshev].end(),y-chebyshev);
		deg+=lower_bound(c2[y-chebyshev].begin(),c2[y-chebyshev].end(),x+chebyshev)-upper_bound(c2[y-chebyshev].begin(),c2[y-chebyshev].end(),x-chebyshev);
		deg+=lower_bound(c2[y+chebyshev].begin(),c2[y+chebyshev].end(),x+chebyshev)-upper_bound(c2[y+chebyshev].begin(),c2[y+chebyshev].end(),x-chebyshev);
	}
	cout<<deg/2ll<<'\n';
}



Measured memory_bytes: 93376
N=int(input())
L=list(map(int, input().split()))

count=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            lengths = [L[i], L[j], L[k]]
            lengths.sort()
            if lengths[0] + lengths[1] > lengths[2]:
                count += 1

print(count)


Measured memory_bytes: 73760
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
// setprecision(n)
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
int main() {
    int n,k;
    cin >> n >> k;

    double ans = 0;
    for (int i =1;i<=n;i++) {
        int a = i;
        double tmp = 1;
        while (a <k) {
            a *=2;
            tmp /=2;
        }
        ans += (double)((double) 1/n * tmp);
    }
    cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 3172
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
mod=10**9+7

A,B=MI()
S=input()

f=1
for i in range(A+B+1):
    if i==A:
        if S[i]!="-":
            f=0
    else:
        if S[i]=="-":
            f=0
            
if f==1:
    print("Yes")
else:
    print("No")





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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll N;
  scanf("%lld",&N);
  double ans=0.0;
  for(int i = 0 ; i < N ; i++){
    double x; cin>>x;
    string u; cin>>u;
    if (u=="JPY") {
      ans += x;
    } else {
      ans += x*380000.0;
    }
  }
  printf("%lf\n",ans);
}

int main()
{
  solve();
  return 0;
}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
    return arg1.first > arg2.first;
}

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

    vector<int> a(n);
    vector<int> memo(1e5+1);
    int ain;
    for(int i=0;i<n;i++) {
        cin >> ain;
        a.at(i) = ain;
        memo.at(ain)++;
    }

    int ans=0;
    for(int i=1;i<=1e5-1;i++) {
        ans = max(ans, memo.at(i-1)+memo.at(i)+memo.at(i+1));
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;


public class Main {
    static void answer(int X){
        System.out.println(X);
        System.exit(0);
    }
    static void impossible(){
        System.out.println(":(");
        System.exit(0);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        for(int x=1; x<100000; x++){
            int n = x*108/100;
            if(n==N) answer(x);
        }
        impossible();
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(0, min(b,d) - max(a,c)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
     string s;
     cin>>s;
     ll m=0;
     for(int i=0;i<3;i++)
     {
         ll c=0;
         for(int j=i;j<3;j++)
         {
             if(s[j]=='R')
             c++;
             else
             break;
             m=max(m,c);
         }
     }
    cout<<m;}
    
    
    
    
    
    

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define sz              size()
#define pb              push_back
#define Fr              first
#define Sc              second
#define Log2(x)         (31^__builtin_clz(x))
#define endl            "\n"
#define int             ll
using namespace std;
typedef long long ll;
int dp[200200];
int n, k;
int A[200200];
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> k;
    for(int i = 0 ; i < n ; i++) cin >> A[i];
    for(int i = n ; i <= n + 300 ; i++) dp[i] = 0;
    for(int i = 0 ; i < n ; i++) dp[i] = 1e9;
    for(int i = 0 ; i < n ; i++) {
        if(dp[i] == 1e9) dp[i] = 0;
        for(int j = 1 ; j <= k ; j++)
            dp[i + j] = min(dp[i + j], dp[i] + abs(A[i] - A[i + j]));
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;
set<int>s;
int main(){
    int x;
    for(int i=1;i<=3;i++){
        scanf("%d",&x);
        s.insert(x);
    }
    cout<<(s.size()==2?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, ans = 0;
    cin >> n;
    int a[n * 2];
    for (int i = 0; i < n * 2; i++) cin >> a[i];
    sort(a, a + n * 2);
    for (int i = 0; i < n * 2; i += 2) ans += a[i];
    cout << ans << endl;
    return 0;//dafsaf
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 105;
int a[maxN];
int x;
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> n >> x;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    ll cost = 0;
    for (int i = 1; i <= n; i++) {
        if (cost + a[i] > x) {
            cout << i - 1;
            return 0;
        }
        cost += a[i];
    }
    if (cost == x) cout << n;
    else cout << n - 1;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min({ a + b,b + c,c + a }) << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        string S = NextString();
        if (S == "AKIHABARA" ||
            S == "AKIHABAR" ||
            S == "AKIHABRA" ||
            S == "AKIHBARA" ||
            S == "KIHABARA" ||
            S == "AKIHABR" ||
            S == "AKIHBAR" ||
            S == "KIHABAR" ||
            S == "AKIHBRA" ||
            S == "KIHABRA" ||
            S == "KIHBARA" ||
            S == "AKIHBR" ||
            S == "KIHBAR" ||
            S == "KIHABR" ||
            S == "KIHBRA" ||
            S == "KIHBR") Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int n; cin >> n;
    vector<ll> S(n);
    rep(i,n) cin >> S[i];
    int q; cin >> q;
    vector<ll> T(q);
    rep(i,q) cin >> T[i];

    int ans = 0;
    rep(i,q) {
        if (binary_search(S.begin(), S.end(), T[i])) ++ans;
    }
    out(ans);

    return 0;
}











Measured memory_bytes: 3760
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define endl '\n'
#define PB pop_back
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
int a , b , gcdd;
int32_t main()
{
		cin >> a >> b;
		return cout << (a * b) / (__gcd(a , b)) << endl , 0;
}
	


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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N;
    cin >> N;
    int a = N % 10;
    int b = N / 100;
    if (a == b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int a, b, t; cin >> a >> b >> t;
  cout << b * (t / a) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 (ll)1 << 60
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>



#define PP pair<ll, P>
ll n, ans = 0;
vector<P> a, b;
vector<PP> c;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

UnionFind u(110000);
int main() {
	cin >> n;
	REP(i, n) {
		ll x, y;
		cin >> x >> y;
		a.push_back(P(x, i));
		b.push_back(P(y, i));
	}
	sort(ALL(a));
	sort(ALL(b));
	REP(i, n - 1) {
		c.push_back(PP(abs(a[i].first - a[i + 1].first), P(a[i].second, a[i + 1].second)));
		c.push_back(PP(abs(b[i].first - b[i + 1].first), P(b[i].second, b[i + 1].second)));
	}
	sort(ALL(c));
	REP(i, c.size()) {
		if (!u.findSet(c[i].second.first, c[i].second.second)) {
			u.unionSet(c[i].second.first, c[i].second.second);
			ans += c[i].first;
		}
	}
	cout << ans << endl;
}




Measured memory_bytes: 13536
A,B=[int(a) for a in input().split()]

minA=(A*125+9)//10
maxA=((A+1)*125+9)//10 - 1
minB=(B*100+9)//10
maxB=((B+1)*100+9)//10 - 1
#print(minA,maxA,minB,maxB)
if max(minA,minB) <= min(maxA,maxB):
    print(max(minA,minB))
else:
    print(-1)



Measured memory_bytes: 3060
#include <iostream>

const long long int mod = static_cast<long long int>(1e9 + 7);

int main() {

    long long int n;
    std::cin >> n;

    long long int power = 1;

    for(long long int i=1; i<=n; i++){
        power *= i;
        power %= mod;
    }

    std::cout << power << std::endl;
    return 0;
}


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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

int main(void){
    ll k;
    cin >> k;
    if(k % 2 == 0 || k % 5 == 0){
        cout << -1 << endl;
    } else{
    int i = 1;
    ll rem = 0;
    ll num = 7;
    while(1){
        num = num % k;
        rem += num;
        if(rem % k == 0){
            cout << i << endl;
            break;
        }
        num *= 10;
        i++;
    }   
} 
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	int n, k;
	std::cin >> n >> k;

	std::vector<int> l(n);
	for(int i = 0; i < n; i++)std::cin >> l[i];

	std::sort(l.rbegin(), l.rend());

	int ans = 0;
	for(int i = 0; i < k; i++)ans += l[i];

	std::cout << ans << std::endl;

	
}	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int S = sc.nextInt();
        int cnt = 0;

        for (int x = 0; x <= K; x++) {
            for (int y = 0; y <= K; y++) {
                int z = S - x -y;
                if(z >= 0 && z <=K ) {
                    cnt++;
                }
            }
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int ans = min(b, d) - max(a, c);

    cout << (ans > 0 ? ans : 0) << endl;

    return 0;
}


Measured memory_bytes: 256
import heapq
import sys
input = sys.stdin.readline

MAX  = 10 ** 15

N, M, s, t = map(int, input().split())

g1 = [[] for _ in range(N + 1)]
g2 = [[] for _ in range(N + 1)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    
    g1[u].append((a, v))
    g1[v].append((a, u))
    
    g2[u].append((b, v))
    g2[v].append((b, u))

d1 = [MAX] * (N + 1)
d2 = [MAX] * (N + 1)

d1[s] = 0 #始点の距離を0にする
pque = []
heapq.heappush(pque, [0, s]) #要素を[距離、頂点]として管理　最初の位置を入れる

while len(pque) != 0: #queの中に要素が残っている時
    p = heapq.heappop(pque) #最も距離が短いものを取り出す
    v = p[1] #距離が最も短い頂点
    if d1[v] < p[0]: #取り出した値より既に小さい値がdに入っているときは無視して次へ
        continue
    for i in range(len(g1[v])): #頂点vの隣接リストを走査
        e = g1[v][i]
        if d1[e[1]] > d1[v] + e[0]: #距離が更新できるかを検討
            d1[e[1]] = d1[v] + e[0]
            heapq.heappush(pque, [d1[e[1]], e[1]]) #更新できた場合、その値をpqueに入れる

# print (d1)

d2[t] = 0 #始点の距離を0にする
pque = []
heapq.heappush(pque, [0, t]) #要素を[距離、頂点]として管理　最初の位置を入れる

while len(pque) != 0: #queの中に要素が残っている時
    p = heapq.heappop(pque) #最も距離が短いものを取り出す
    v = p[1] #距離が最も短い頂点
    if d2[v] < p[0]: #取り出した値より既に小さい値がdに入っているときは無視して次へ
        continue
    for i in range(len(g2[v])): #頂点vの隣接リストを走査
        e = g2[v][i]
        if d2[e[1]] > d2[v] + e[0]: #距離が更新できるかを検討
            d2[e[1]] = d2[v] + e[0]
            heapq.heappush(pque, [d2[e[1]], e[1]]) #更新できた場合、その値をpqueに入れる

# print (d2)

tmp = MAX
ans = [MAX] * N
for i in range(N, 0, -1):
    tmp = min(tmp, d1[i] + d2[i])
    ans[i - 1] -= tmp

print (*ans, sep = '\n')

Measured memory_bytes: 81564