akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
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; }
const ll INF = 1LL << 60;
const ll mod = 1000000007;

bool prime(ll x){
	if(x==1) return false;
	for(ll i=2; i*i<=x; i++){
		if(x%i==0) return false;
	}
	return true;
}

int main(){
	//乱数srand((unsigned)time(NULL));
	ll X; cin>>X;
	ll ans=X;
	while(!prime(ans)) ans++;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;

bool is_prime(int n){
    if (n < 2){
        return false;
    }
    int i;
    for (i = 2; i*i <= n; i++){
        if (n%i == 0){
            return false;
        }
    }
    return true;
}

int sushu[100005];
int cnt[100005];
int main()
{
    sushu[2] = 1;
    sushu[3] = 1;
    for(int i = 5; i <= 100005; i+=2){
        if(is_prime(i))
            sushu[i] = 1;
    }
    for(int i = 0; i <= 100000; i++){
        cnt[i] += cnt[i-1];
        if(sushu[i]&&sushu[(i+1)/2]){
            //cout << i << endl;
            cnt[i]++;
        }

    }
    int n;
    cin >> n;
    int a,b;
    for(int i = 0; i < n; i++){
        cin >> a>>b;
        cout << cnt[b] - cnt[a-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  long long a = 1;
  long long inf = 1e18;
  vector<long long>num(N);
  for (int i = 0; i < N; i ++) {
    cin >> num[i];
    if (num[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i ++) {
    long long k = num[i];
    if (k == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (k > inf / a) {
      cout << -1 << endl;
      return 0;
    }
    a *= k;
  }
  cout << a << endl;
}



Measured memory_bytes: 4048
N=int(input())

mul_num = [1]*(N+1)
#print(mul_num)
for i in range(N,2,-1):
    #print(i)
    for j in range(2,i):
        if i%j==0:
            mul_num[int(i/j)] += mul_num[i]
            mul_num[j] += mul_num[i]
            mul_num[i] =0

#print(mul_num)
ans=1
for i in mul_num[2:]:
    if i>0:
      ans *= (i+1)
print(ans%(10**9+7))

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    for (int x = a; x <= a * 100; x += a)
    {
        if (x % b == c)
        {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3620
import math

X = int(input())

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

  
while True:
  if is_prime(X):
    print(X)
    break
  X +=1
    

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
using namespace std;

int main()
{
    int n;
    int i, j, al = 0, bo = 0;
    
    cin >> n;
    
    int a[n];
    
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    sort(a, a+n);
    
    for(j = n-1; j >= 0; j--) {
        if(((n % 2 == 1)&&(j%2 == 0)) || ((n % 2 == 0)&&(j % 2 == 1))) {
            al = al + a[j];
        } else {
            bo = bo + a[j];
        }
    }
    
    cout << al-bo << endl;
    
    return 0;
}

Measured memory_bytes: 256
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
入力Pを何個かの塊にわかる
塊の中では1個の駒による操作が行われる、
1回にとなりの1ますに歯科移動できない
すなわちそのなかでの最大と最小の差の絶対値

"""
#solution:
#潜 影 蛇 手 ! !
N,M=pin()
P=sorted(list(pin()))#大小関係を整理する
#print("*",P)
PP=[abs(P[j+1]-P[j]) for j in range(M-1)]
#print(PP)
Q=sorted(PP)
#print(Q)
if N>=M:#この場合必ず1個の拠点に1個以上のコマが置けるのでこのままでいい
    print(0)
else:
    for i in range(N-1):
        Q.pop()
    print(sum(Q))
    

Measured memory_bytes: 13960
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <set>
# include <map>
# include <stack>
using namespace std;
# define M_PI 3.141592
# define FOR(i,n) for(int i=0;i<(int)n;i++)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define toRad 2.0*M_PI/360.0
# define inin(x) int x;cin>>x;
# define all(x) x.begin(),x.end()
# define debug(x) cout<<#x<<" :"<<x<<endl;
# define rep(i,n) for(int i=0;i<(int)n;i++)
# define EPS 1e-12
# define pri_max 60000
# define CHECK(i,a) FOR(i,a.size())cout<<#a<<"["<<i<<"] : "<<a[i]<<endl; 
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	int n;
	while (cin >> n&&n)
	{
		for (int i = 0; i < n; i++)
		{
			int a[3][4] = {};
			for (int i = 0; i < 2; i++)
			{
				for (int l = 0; l < 4; l++)
				{
					cin >> a[i][l];
				}
			}

			int dx[4][4] = 
			{
				{0,1,2,3},
				{1,0,3,2},
				{2,3,0,1},
				{3,2,1,0}
			},
				dy[4][4]=
			{
				{1,1,1,1},
				{1,-1,1,-1},
				{1,-1,-1,1},
				{1,1,-1,-1}
			};

			for (int i = 0; i < 4; i++)
			{
				for (int l = 0; l < 4; l++)
				{
					a[2][dx[i][l]] += dy[i][l] * a[0][i] * a[1][l];
				}
			}
			cout << a[2][0] << " " << a[2][1] << " " << a[2][2] << " " << a[2][3] << endl;



		}
	}
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>
int g[26][26];
int dfs(int a,int n)
{
  int i;
  if(n==0)return 1;
  for(i=0;i<26;i++){
    if(g[a][i]){
      g[a][i]--;
      if(dfs(i,n-1))return 1;
      g[a][i]++;
    }
  }
  return 0;
}
int main(void)
{
  int n,i,t[26],l,f;
  char s[33];
  for(;;){
    scanf("%d",&n); if(!n)break;
    memset(t,0,sizeof(t));
    memset(g,0,sizeof(g));
    for(i=0;i<n;i++){
      scanf("%s",s);
      l=strlen(s)-1;
      t[s[0]-'a']++;
      t[s[l]-'a']--;
      g[s[0]-'a'][s[l]-'a']++;
    }
    f=1;
    for(i=0;i<26;i++){
      if(t[i])f=0;
    }
    if(f)f=dfs(s[0]-'a',n);
    puts(f?"OK":"NG");
  }
  return 0;
}

Measured memory_bytes: 0
from collections import Counter
mod = 10 ** 9 + 7
n = int(input())
A = Counter([int(i) for i in input().split()])

flag = 0
cnt = 0
if n % 2 == 1:
    for k, v in A.items():
        if  k != 0 and v == 2:
            cnt += 1
        elif k == 0 and v == 1:
            pass
        else:
            flag = 1
else:
    for k, v in A.items():
        if v == 2:
            cnt += 1
        else:
            flag = 1
            
if flag == 1:
    print(0)
else:
    print(2 ** cnt % mod)

Measured memory_bytes: 14820
n,h = map(int, input().split())

ka = []
th = []

for _ in range(n):
    a, b = map(int, input().split())
    ka.append(a)
    th.append(b)

ths = sorted(th)
thr = sorted(th, reverse=True)

import itertools
sumthr = list(itertools.accumulate(thr))

mk = max(ka)

if mk >= max(th):
    print(-(-h//mk))
    exit()


import bisect
t = bisect.bisect(ths,mk)

res = 0
for i in range(n-t):
    if h > sumthr[i]:
        pass
    else:
        print(i+1)
        exit()

    if i ==n-1:
        print(-((sumthr[-1]-h)//mk)+i+1)
        exit()

print(-((sumthr[i]-h)//mk)+i+1)

Measured memory_bytes: 17456
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
A = [[] for _ in range(N)]
for i in range(N):
    A[i] = list(map(int, input().split()))

n = 0
for i in range(N):
    f = 0
    for j in range(M):
        f += A[i][j]*B[j]
    f += C
    if f>0:
        n += 1
        
print(n)

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

int main()
{
 int a,b;
  cin>>a>>b;
  string nish;
  cin>>nish;
  for(int i=1;i<=a;i++)
  {
    if(i==b)
    {
      nish[i-1]=tolower(nish[i-1]);
    }
  }
  
  cout<<nish<<endl;
  
return 0;
}

Measured memory_bytes: 3568
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Collections;
import java.util.ArrayList;
import java.util.List;
import java.util.HashSet;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Comparator;

public class Main {
    // 標準入力
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    // 標準入力数値配列用 int
    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    // 標準入力数値リスト用 int
    static List<Integer> inputIntList() throws Exception {
        List<String> strList = Arrays.asList(br.readLine().trim().split(" "));
        List<Integer> intList = new ArrayList<Integer>();
        for (String elem : strList){
            intList.add(Integer.parseInt(elem));
        }
        return intList;
    }

    // 標準入力数値配列用 integer ソート用
    static Integer[] inputvalInteger() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        Integer[] intarray = new Integer[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    public static void main(String[] args) throws Exception {
        // write your code here
        String s = br.readLine();
        int ap = -1;
        int zp = -1;
        for (int i=0; i<s.length(); i++){
            if (s.charAt(i) == 'A'){
                ap = i;
                break;
            }
        }
        for (int j=s.length()-1; j>=0; j--){
            if (s.charAt(j) == 'Z'){
                zp = j;
                break;
            }
        }
        System.out.println(zp-ap+1);

    }

}



Measured memory_bytes: 36204
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<bitset>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;

typedef long long LL;
typedef long double LD;
const int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    LL x;
    cin >> x;
    
    LL p = 100, ans = 0;
    while(p < x){
        p += p / 100;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[N][N];
int color[N],d[N],f[N],tt;
void dfs(int);
void hint(void);
int main(){
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  hint();
  return 0;
}
void dfs(int u){
  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}
void hint(){
  int u;
  for(u=0;u<n;u++)color[u]=WHITE;
  tt=0;
  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs(u);
  }
  for(u=0;u<n;u++)
    printf("%d %d %d\n",u+1,d[u],f[u]);
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define ll long long
#define oo 1000000010
using namespace std;

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

	ll n, m, sum = 0;
	cin >> n >> m;
	ll a[m+1];
	for(int i=0; i<m; i++) cin >> a[i], sum+=a[i];

	if(sum <= n) cout << n - sum;
	else cout << "-1";

	return 0;
}


Measured memory_bytes: 3684
def hantei(N):
    if N % 2 == 0:
        if N % 3 == 0 or N % 5 == 0:
            return True
        else:
            return False
    else:
        return True

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

for i in A:
    if hantei(i):
        continue
    else:
        print("DENIED")
        break
else:
    print("APPROVED")

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

using namespace std;

bool END;
string s;

void check(string b){
    if (END)
        return;
    int k = s[0] - '0';
    for (int i = 0; i < 3; i++){
        if (b[i] == '1')
            k += s[i + 1] - '0';
        else
            k -= s[i + 1] - '0';
    }
    b += '2';
    if (k == 7){
        for (int i = 0; i < 4; i++){
            cout << s[i];
        if (b[i] == '1')
            cout << '+';
        else if (b[i] == '0')
            cout << '-';
        else
            cout << "=7";
        }
        END = true;
    }
}

void findans(string b){
    if (b.size() == 3){
        check(b);
        return;
    }
    findans(b + '0');
    findans(b + '1');
}

int main(){
    cin >> s;
    string b;
    findans(b);
}


Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <vector>
#include <fstream>

using namespace std;

#define ll long long int

#define rep(i, start, end) for (int i = (int)(start); i < (int)(end); i++)
#define charToInt(c) c - 'a'
#define MAX_ITEM 10000000000


int main(int argc, const char *argv[])
{
    //デバッグ用コード
    //std::ifstream in("/Users/tolemy/Downloads/D (1)/in/in07.txt");
    //std::cin.rdbuf(in.rdbuf());

    //方針
    //a,b,cをバラバラにずらしながら計算するのは難しい。
    //bとcの和をあらかじめ計算しておいて、aの値から条件を満たすbとcの和を検索する。
    
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    
    vector<ll> as(x);
    rep(i, 0, x)
    {
        cin >> as[i];
    }
    sort(as.begin(), as.end(), greater<ll>());
    
    vector<ll> bs(y);
    rep(i, 0, y)
    {
        cin >> bs[i];
    }
    
    vector<ll> cs(x);
    rep(i, 0, z)
    {
        cin >> cs[i];
    }

    //bとcの和を計算
    vector<ll> sums;
    for(ll b:bs)
    {
        for(ll c:cs)
        {
            sums.push_back(b + c);
        }
    }
    //sort(sums.begin(), sums.end(), greater<ll>());
    sort(sums.begin(), sums.end(), greater<ll>());
    
    //a,b,cの和の計算と表示
    ll total = as[0] + sums[0];

    bool flg = true;
    int i = 0;
    while(flg)
    {
        ll total_next = 0;
        for(int j=0;j<as.size() && flg;j++)
        {
            //値の検索
            //value「以下」の値を検索する。
            ll value = total - as[j];
            auto iter = lower_bound(sums.begin(), sums.end(), value, greater<ll>());

            //見つからなかった場合は、aの後続を探しても無駄なのでスキップ
            //if(iter == sums.end())
            //{
            //    break;
            //}

            //同じ値が複数あることを考慮して、ループで全て表示
            //sumの値が小さくなる方向にループ
            while(iter != sums.end())
            {
                //現在考えている合計値より小さい場合は退避した上で表示ループ終了。
                if(*iter < value)
                {
                    ll tmp = *iter + as[j];
                    if(total_next < tmp)
                    {
                        total_next = tmp;
                    }
                    break;
                }

                //現在考えている合計値の場合は表示。
                cout << total << endl;
                i++;
                ++iter;

                if(i >= k)
                {
                    flg = false;
                    break;
                }
            }
        }
        
        total = total_next;
    }
    
    
    return 0;

}


Measured memory_bytes: 10352
#include <iostream>
#include <vector>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
  int H, W;
  cin >> H >> W;

  vector<string> field(H);
  for(int i = 0; i < H; i++){
    cin >> field[i];
  }

  vector<pair<int, int>> iB;
  int spn = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(field[i][j] == '#'){
        iB.push_back(make_pair(i, j));
        spn += 1;
      }
    }
  }

  vector<vector<int>> dist(H, vector<int>(W,-1));
  queue<pair<int, int>> que;

  vector<bool> isFinished(spn,0);
  bool isAllFinished = false;

  for(int pn = 0; pn < spn; pn++){
    pair<int, int> cs = iB[pn];
    int csx = cs.second;
    int csy = cs.first;

    que.push(make_pair(csy, csx));
    dist[csy][csx] = 0;
  }

  int distMax = 0;
  while(!que.empty()){
    pair<int, int> cp = que.front();
    int cx = cp.second;
    int cy = cp.first;
    que.pop();
    for(int i = 0; i < 4; i++){
      int nx = cx + dx[i];
      int ny = cy + dy[i];
      if(nx < 0 || nx >= W || ny < 0 || ny >= H)continue;
      if(dist[ny][nx] != -1) continue;
      dist[ny][nx] = dist[cy][cx] + 1;
      if(distMax < dist[ny][nx]) distMax = dist[ny][nx];
      que.push(make_pair(ny, nx));
    }
  }

  cout << distMax << endl;

  return 0;
}



Measured memory_bytes: 21488
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>

using namespace std;

int main () {
  int n, m;
  cin >> n >> m;

  vector<int> from_0, to_n, result;

  while (m--) {
    int a, b;
    cin >> a >> b;
    if (a == 1) {
      from_0.push_back(b-1);
    }
    if (b == n) {
      to_n.push_back(a-1);
    }
  }

  sort(from_0.begin(), from_0.end());
  sort(to_n.begin(), to_n.end());

  set_intersection(from_0.begin(), from_0.end(),
      to_n.begin(), to_n.end(),
      back_inserter(result));

  cout << ( result.size() ? "POSSIBLE" : "IMPOSSIBLE" ) << endl;

  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll cnt = 0;
    for(ll i=0; (i + 3)<=n; i++)
    {
        if(s[i] == 'A' && s[i + 1]=='B' && s[i+2] == 'C')
            cnt++;
    }
    cout<<cnt<<'\n';
}

Measured memory_bytes: 3616
n = int(input())
a = [0] + list(map(int, input().split()))
pr = [0]
al = [0]
for i in range(n-1):
    pr.append(abs(a[i] - a[i+2]))
    al.append(abs(a[i] - a[i+1]) + al[i])
al.append(abs(a[-2] - a[-1]) + al[-1])
al.append(al[-1]+abs(a[-1]))
if n == 2:
    print(2*abs(a[2]))
    print(2*abs(a[1]))
else:
    for i in range(n):
        if i == 0:
            if a[1]*a[2] > 0:
                ans = al[-1] + pr[1] - al[2]
            else:
                ans = al[-1] - abs(2*a[1])

        elif i < n-1:
            ans = al[-1] + al[i] - al[i+2] + pr[i+1]
        else:
            ans = al[-3] + abs(a[-2])
        print(ans)

Measured memory_bytes: 65260
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

int main(){
	int n,m[100001];
	cin>>n;
	int a=0,b=0;
	for(int i=0;i<n;i++){
		cin>>m[i];
		if(m[i]%2==0&&m[i]%4!=0) a++;
		if(m[i]%4==0) b++;
	}
	if(a==n) cout<<"Yes";
	else if(b>=n/2) cout<<"Yes";
	else if(a+b>=n-b) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    H.push_back(1e9 + 7);

    int ans = 0;
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (H[i] >= H[i + 1]) cnt++;
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
        if (i == N - 1) ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int a[200010];

int main(void){
	          int i;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  int N,K;
	      	  cin >> N >> K;
	      	  for(i=1;i<=N;i++){
	      		  int x;
	      		  cin >> x;
	      		  a[x]++;
	      	  }

	      	  vector<int> v;
	      	  for(i=1;i<=200000;i++) if(a[i]!=0) v.push_back(a[i]);

	      	  sort(v.begin(),v.end());
	      	  int n=v.size();

	      	  ll ans=0;
	      	  for(i=0;i<n-K;i++) ans+=(ll)v[i];

	      	  cout << ans << endl;


	          return 0;
}


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

int main(void)
{
    int K;

    cin >> K;

    if(K % 2 == 0 || K % 5 == 0)
    {
        cout << -1 << endl;
        return 0;
    }

    long long int ans = 1;
    int i = 7;
    while(1)
    {
        if(i % K == 0) break;
        i = i % K;
        i = i * 10 + 7;
        ++ ans;
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    cin.tie(NULL); cout.tie(NULL);
    ios_base:: sync_with_stdio(false);
    ll n,a,b,c,d;cin>>n>>a>>b>>c>>d;
    string s;cin>>s;
    s='.'+s;
    for(ll i=a;i<c;i++)if(s[i]=='#' && s[i+1]=='#')return cout<<"No" , 0;
    for(ll i=b;i<d;i++)if(s[i]=='#' && s[i+1]=='#')return cout<<"No" , 0;
    if(c<d)return cout<<"Yes" , 0;
    for(ll i=b-1;i<d && i+1<n ;i++)if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.')return cout<<"Yes" , 0;
    cout<<"No";
}




Measured memory_bytes: 720
#include<cstdio>
#include<algorithm>

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

using namespace std;

int main(){
	for(int n,t;scanf("%d%d",&n,&t),n;){
		char ring[2001];	scanf("%s",ring);

		double dp[2][12001];
		dp[0][0]=1;
		for(int i=1;i<=t;i++){
			rep(j,i)	dp[i&1][j]=0;
			for(int j=i;j<=6*i;j++){
				dp[i&1][j]=0;
				for(int k=1;k<=6;k++){
					if(0<=j-k && j-k<=6*(i-1))	dp[i&1][j]+=dp[(i-1)&1][j-k];
				}
				dp[i&1][j]/=6;
			}
		}

		double pr[2000]={};
		for(int i=1;i<=6*t;i++)	pr[i%n]+=dp[t%2][i];

		double prmax=0;
		rep(d,n){
			double prtmp=0;
			rep(i,n)if(ring[i]=='R'){
				prtmp+=pr[(i+d)%n];
			}
			prmax=max(prmax,prtmp);
		}
		printf("%.9f\n",prmax);
	}

	return 0;
}

Measured memory_bytes: 1008
#pragma GCC optimize(2)
#include<bits/stdc++.h>
typedef long long ll;
const int maxn=1e6+5;
using namespace std;
const ll INF=1e13+7;
ll n,m;
char str[maxn];
ll dp[maxn];
ll q[maxn];
int pre[maxn];
void TraceBack(int x)
{
    if(pre[x]==-1)
    {
        printf("%d",x);
        return;
    }
    TraceBack(pre[x]);
    printf(" %d",x-pre[x]);
}
int main()
{
    memset(pre,-1,sizeof(pre));
    scanf("%lld%lld",&n,&m);
    scanf("%s",str);
    //数有n+1个
    int s=1,e=0;
    for(int i=0;i<=m;i++)
    {
        if(str[i]=='0')
            dp[i]=1;
        else
            dp[i]=INF;
        while(s<=e&&dp[i]<dp[q[e]])
            e--;
        q[++e]=i;
    }
    s++;
    for(int i=m+1; i<=n; i++)
    {
        dp[i]=INF;
        if(str[i]=='0')
        {
            dp[i]=min(dp[q[s]]+1,dp[i]);
            if(!dp[i]!=INF)
                pre[i]=q[s];
        }
        while(s<=e&&dp[i]<dp[q[e]])
            e--;
        q[++e]=i;
        while(s<=e&&q[s]<i+1-m)
            s++;
    }
    if(dp[n]==INF) printf("-1\n");
    else
        TraceBack(n);
    return 0;
}

/**

**/


Measured memory_bytes: 15872
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();
        var T2 = T + T;
        Console.WriteLine(T2.IndexOf(S) >= 0 ? "Yes" : "No");
    }
}

Measured memory_bytes: 13280
main :: IO ()
main = do
  s <- getLine
  putStrLn $ if easilyPlyable s then "Yes" else "No"

easilyPlyable :: String -> Bool
easilyPlyable []        = True
easilyPlyable ('L':_)   = False
easilyPlyable [_]       = True
easilyPlyable (_:'R':_) = False
easilyPlyable (_:_:xs)  = easilyPlyable xs

Measured memory_bytes: 380
from collections import deque
n,m = map(int, input().split())
dis = [n+2]*(n)
dis[0] = 0
near = [[] for _ in range(n)]
mark = [-1]*(n)
mark[0] = 0
que = deque()
for _ in range(m):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  near[a].append(b)
  near[b].append(a)
  if a==0:
    que.appendleft(b)
    mark[b] = 0
    dis[b] = 1
  if b==0:
    que.appendleft(a)
    mark[a] = 0
    dis[a] = 1
while que:
  i = que.popleft()
  for j in near[i]:
    if dis[i]+1<dis[j]:
      dis[j] = dis[i]+1
      mark[j] = i
      que.append(j)
if n+2 not in dis:
  print('Yes')
  for i in mark[1:]:
    print(i+1)
else:
  print('No')

Measured memory_bytes: 36060
card = 3.times.map { gets.split(" ").map(&:to_i) }
n = gets.to_i
bs = n.times.map { gets.to_i }

result = false
bool_card = [[false,false,false], [false,false,false], [false,false,false]]

bs.each do |i|
    3.times do |j|
        3.times do |k|
            if card[j][k] == i
                bool_card[j][k] = true
            end
        end
    end
end

3.times do |j|
    result = true if bool_card[j].all? || bool_card.transpose[j].all?
end

unless result
    result = true if (bool_card[0][0] && bool_card[1][1] && bool_card[2][2]) || (bool_card[0][2] && bool_card[1][1] && bool_card[2][0])
end

puts result ? :Yes : :No

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<vector<ll>> graph;

//dp
vector<vector<ll>> table;
vector<ll> checked;

ll dp(ll sep,ll v){
  //cout<<sep<<" "<<v<<endl;
  if(table.at(sep).at(v)>-1) return table.at(sep).at(v);
  
  ll ret=1;
  if(sep==0){
    for(auto nv:graph.at(v)){
      if(nv==checked.at(v)) continue;
      checked.at(nv)=v;
      ret=ret*(dp(0,nv)+dp(1,nv))%MOD;
    }
  }
  else{
    for(auto nv:graph.at(v)){
      if(nv==checked.at(v)) continue;
      checked.at(nv)=v;
      ret=ret*dp(0,nv)%MOD;
    }
  }
  
  return table.at(sep).at(v)=ret;
}

int main()
{
  ll N; cin>>N;
  graph=vector<vector<ll>>(N,vector<ll>(0));
  rep(i,N-1){
    ll x,y; cin>>x>>y; x--; y--;
    graph.at(x).push_back(y);
    graph.at(y).push_back(x);
  }
  
  //dp
  table=vector<vector<ll>>(2,vector<ll>(N,-1));
  checked=vector<ll>(N,-1);
  
  cout<<(dp(0,0)+dp(1,0))%MOD<<endl;
  
  return 0;
}

Measured memory_bytes: 32108
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
 
 
int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;++i) cin >> a[i];
 
  sort(a.rbegin(),a.rend());
  ll ans=0;
  int ti=n-1;
  for(int i=0;i<n;++i){
    int l=2;
    if(i==0)l=1;
    for(int j=0;j<l;++j){
      if(ti>0){
        ans+=a[i];
        ti--;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  int n;
  cin >> n;
  vi x(n);
  REP(i,n) {
    x[i]=i+1;
  }
  vi p(n),q(n);
  REP(i,n) {
    cin >> p[i];
  }
  REP(i,n) {
    cin >> q[i];
  }
  map<vi,int> cnt;
  int c=0;
  do {
    cnt[x]=c;
    c++;
  } while(next_permutation(ALL(x)));
  int ans=cnt[p]-cnt[q];
  cout << abs(ans) << endl;
  return 0;
}


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

using ll = long long;
using namespace std;

ll n,a,b,k,ans = 0;
ll mod = 998244353;

ll fact[1000000];

ll extgcd(ll a,ll b,ll& x,ll& y){
	ll d = a;
	if(b != 0) {
		d = extgcd(b,a%b,y,x);
		y -= (a/b) * x;
	}else{
		x = 1; y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return (m + x % m) % m;
}

ll mod_fact(ll n,ll p ,ll& e){
	e = 0;
	if(n == 0) return 1;
	ll res = mod_fact(n/p,p,e);
	if(n/p%2 != 0 ) return res * (p - fact[n%p]) % p;
	return res *fact[n%p] % p;
}

ll mod_comb(ll n,ll k,ll p) {
	if(n < 0 || k < 0 || n < k) return 0;
	ll e1,e2,e3;
	ll a1 = mod_fact(n,p,e1), a2 = mod_fact(k,p,e2), a3 = mod_fact(n-k,p,e3);
	if(e1 > e2 + e3) return 0;
	return a1 * mod_inverse(a2 * a3 % p,p) % p;
}

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

	cin >> n >> a >> b >> k;

	ll g = a+b;

	fact[0] = 0;
	fact[1] = 1;

	for (ll i = 2;i < 1000000;i++){
		fact[i] = (fact[i-1] * i) % mod;
	}

	for(ll i = 0;i<=n;i++){
		if(i > n) break;
		ll c = k - i*a;
		if(c%b == 0){
			ll j = c/b;
			ans += (mod_comb(n,i,mod)*mod_comb(n,j,mod))%mod;
			ans %= mod;
		}

	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
typedef long long ll;
int main(){
    int H,W,N;
    cin>>H>>W>>N;
    int a=max(H,W);
    /*
    if(N%a==0){
        cout<<N/a<<endl;
    }else{
        cout<<N/a+1<<endl;
    }
    */
   cout<<(N+a-1)/a<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

int main()
{
	std::vector<bool> answer;
	std::vector<bool> isWolf;

	int n;
	std::cin >> n;
	answer.resize(n);
	isWolf.resize(n);
	while (getchar() != '\n')
		continue;
	for (int i = 0; i < n; ++i)
		answer[i] = getchar() == 'x';

	bool hasSolution = false;
	for (int start = 0; start < 4; ++start)
	{
		isWolf[0] = start & 1;
		isWolf[1] = start & 2;
		for (int i = 2; i < n; ++i)
			isWolf[i] = (isWolf[i - 2] != isWolf[i - 1] != answer[i - 1]);
		if ((isWolf[n - 2] != isWolf[n - 1] != answer[n - 1]) == isWolf[0] &&
			(isWolf[n - 1] != isWolf[0] != answer[0]) == isWolf[1])
		{
			hasSolution = true;
			break;
		}
	}
	if (hasSolution)
	{
		for (int i = 0; i < n; ++i)
			putchar(isWolf[i] ? 'W' : 'S');
		std::cout << std::endl;
	}
	else
		std::cout << "-1" << std::endl;

	return 0;
}

Measured memory_bytes: 384
import math
def main():
    n,p=map(int,input().split())
    if n==1:
        print(p)
    elif n>39:
        print(1)
    else:
        q=math.ceil(p**(1/n))
        ans=1
        for i in range(q,0,-1):
            if p%(i**n)==0:
                ans=i
                break
        print(ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 38640
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

ll num_of_patty_for(const int n) {
    if (n == 1) return 3LL;
    else return num_of_patty_for(n - 1) * 2LL + 1LL;
}

ll size_of_hamburger_for(const int n) {
    static map<int, ll> memo;
    if (memo.find(n) != memo.end()) {
        return memo[n]; 
    }

    if (n == 1) {
        return 5LL;
    } else {
        ll ans = size_of_hamburger_for(n - 1) * 2LL + 3LL;
        memo[n] = ans;
        return ans;
    }
}

static map<pair<int, ll>, ll> memo;

ll solve(const ll n, ll x) {
    ll res = 0;

    const ll ham_size = size_of_hamburger_for(n);

    if (x > ham_size) {
        x = ham_size;
    }

    if (memo.find({n, x}) != memo.end()) {
        return memo[{n, x}];
    }

    // printf("n: %lld, x: %lld\n", n, x);

    if (n == 1) {
        assert(x >= 1 && x <= 5);
        vector<ll> tmp = {0LL, 0LL, 1LL, 2LL, 3LL, 3LL};
        return tmp[x];
    }

    if (x == 1) {
        return 0LL;
    }

    if (x == (ham_size - 3) / 2 + 2) {
        // at the center
        res++;
        res += solve(n - 1, x - 2); // x - 2 will be fixed later
    } else if (2 * x > ham_size) {
        // left
        res++;
        res += solve(n - 1, x - 2); // x - 2 will be fixed later
        res += solve(n - 1, x - ((ham_size + 2 - 1) / 2));
    } else {
        // right
        res += solve(n - 1, x - 1);
    }

    memo[{n, x}] = res;
    return res;
}

int main(void) {
    ll N, X;
    cin >> N >> X;

    cout << solve(N, X) << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    C = N // 100
    H = N % 100

    for i in [5,4,3,2,1]:
        Ci = H // i
        if Ci > C:
            print(0)
            return
        C -= Ci
        H -= Ci * i
        N -= (100 + i) * Ci
        if N < 0:
            print(0)
            return

    print(1)



if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit
#include <cstdio>	// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
//typedef pair<int, P> PP;

const int INF = 1<<25;
int dp[5][1005];

int main()
{
//	cut here before submit 
//	freopen ("testcase.Pachimon_Creature", "r", stdin );
	int w, h;
	while (cin >> w >> h && w && h ){
		vector <string> m (h );
		rep (i, h ) m[i].clear();

		P s, g;
		vector <P> p[5];
		rep (i, 5 )
			p[i].clear();

		rep (i, h ){
			cin >> m[i];
		} // end rep
		rep (i, h ){
			rep (j, w ){
				if (m[i][j] == 'S' ) s = P (i, j );
				else if (m[i][j] == 'G' ) g = P (i, j );
				else if (isdigit (m[i][j] ) ) p[m[i][j] - '0'- 1 ].push_back (P (i, j ) );
			} // end rep
		} // end rep

		int first_cur = -1;
		int res = INF;
		for (int cur = 0; cur < 5; cur++ ){
			rep (i, 5 ) rep (j, 1005 ) dp[i][j] = INF;
			int nxt = (cur+1)%5;
			// S ツつゥツづァ ツ堕ョツ青ォ:nxt ツづ鳴づ個経ツ路
			for (int j = 0; j < p[nxt].size(); j++ ){
				dp[nxt][j] = abs (p[nxt][j].first - s.first ) + abs (p[nxt][j].second - s.second );
			} // end for
			for (int i = nxt, cnt = 0; cnt < 5; cnt++, i = (i+1) % 5  ){
				for (int j = 0; j < p[(i+1) % 5].size(); j++ ){
					for (int k = 0; k < p[i].size(); k++ ){
						int l = abs (p[(i+1)%5][j].first - p[i][k].first ) + abs (p[(i+1)%5][j].second - p[i][k].second );
						dp[(i+1)%5][j] = min (dp[(i+1)%5][j], dp[i][k] + l );
					} // end for
				} // end for
			} // end for
			// ツ堕ョツ青ォ: (cur-1+5) % 5 ツつゥツづァ G ツづ鳴づ個経ツ路
			for (int j = 0; j < p[(cur-1+5)%5].size(); j++ ){
				int l = dp[(cur-1+5)%5][j] + abs (g.first - p[(cur-1+5)%5][j].first ) + abs (g.second - p[(cur-1+5)%5][j].second );
				if (res > l ) {
					res = l;
					first_cur = cur;
				} // end if
			} // end for
		} // end for

		if (res == INF )
			cout << -1 << endl;
		else
			cout << first_cur+1 << ' ' << res << endl;

	} // end loop
		
	return 0;
}

Measured memory_bytes: 2004
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=41;
const int mod=1e9+7;
int ans=0;
int dp[MAX][1<<17];

int fastpow(int a,int b)
{
	int wynik=1;
	while (b)
	{
		if (b&1)
		wynik=((ll)wynik*a)%mod;
		a=((ll)a*a)%mod;
		b>>=1;
	}
	return wynik;
}

int32_t main()
{
  BOOST;
  int n,x,y,z;
  cin>>n>>x>>y>>z;
  int mask=(1<<(x+y+z))-1;
  ans=fastpow(10,n);
  dp[0][0]=1;
  int num=0;
  num|=(1<<(x-1));
  num|=(1<<(x+y-1));
  num|=(1<<(x+y+z-1));
  for (int i=0;i<n;i++)
  {
  	for (int msk=0;msk<=mask;msk++)
  	{
  		for (int j=1;j<=10;j++)
  		{
  			int to=(msk<<j)|(1<<(j-1));
  			to&=mask;
  			if ((to&num)!=num)dp[i+1][to]=(dp[i+1][to]+dp[i][msk])%mod;
  		}
  	}
  }
  for (int i=0;i<=mask;i++)ans=(ans-dp[n][i]+mod)%mod;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 20736
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

ll gcd(ll a, ll b) {
  while (b > 0) {
    ll rem = a % b;
    a = b;
    b = rem;
  }
  return a;
}

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

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

  int n;
  cin >> n;
  vector<ll> t(n);
  for (auto &x: t) cin >> x;

  ll ans = 1;
  for (auto &x: t) ans = lcm(ans, x);

  cout << ans << endl;

  return 0;
}


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

const i64 mod = 1e9+7;

int main(){
    i64 n,ans=0,a=1,b=1,c=1;
    cin>>n;
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    for(i64 i=0;i<n;i++){
        a *=  10;
        b *= 9;
        c *= 8;
        a %= mod;
        b %= mod;
        c %= mod;
    }
    i64 d = b*2-c;
    d =( mod + d)%mod;
    ans = a-d;
    if(ans<0){
        cout<<mod+ans<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

int search(int a[], int n, int key){
  int i=0;
  a[n]=key;
  while(a[i] != key) i++;

    return i!=n;

}

int main(){

  int i,n,a[10000+1],q,key,sum=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&a[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if( search(a,n,key)) sum++;

}
printf("%d\n",sum);

return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
using namespace std;



class UnionFind {
public:
    vector<int> Parent;
    UnionFind(int N){
        Parent = vector<int>(N,-1);
    }
    
    int root(int node){
        if (Parent[node] < 0){
            return node;
        }
        else{
            return Parent[node] = root(Parent[node]);
        }
    }
    
    int size(int node){
        return -root(node);
    }
    
    bool connect(int A, int B){
        int Aroot = root(A);
        int Broot = root(B);
        if (Aroot != Broot){
            if (size(Aroot) < size(Broot)) swap(Aroot,Broot);
            Parent[Aroot] += Parent[Broot];
            Parent[Broot] = Aroot;
            return true;
        }
        else{
            return false;
        }
    }
};




#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
using ll = long long;




int main(){
    int A,B,C; cin >> A >> B >> C;
    int ans = max(C-A+B,0);
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;
    map<ll, ll> mp;
    rep(i, n) {
        ll a;
        cin >> a;
        mp[a]++;
    }
    ll ans = 0;
    for(auto p : mp) {
        if(p.second%2 == 1) {
            ans++;
        }
    }
    out(ans);
    re0;
}

Measured memory_bytes: 6528
import java.io.*
import java.util.*

fun solve(H: Long, A: Long){
    val ans = H / A + if(H % A == 0L) 0L else 1L
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val H = sc.next().toLong()
    val A = sc.next().toLong()
    solve(H, A)
}



Measured memory_bytes: 31396
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 5000100;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

ll dx[8] = { 0,0,-1,1 };
ll dy[8] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool graph[101][101];
vector<ll> to[101010];
vector<ll>ball(101010, 1);
char c[10][10];
bool visited[10][10];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, k, s;
	cin >> n >> k >> s;
	vector<ll>ans;
	rep(i, k) {
		ans.push_back(s);
	}
	rep(i, n - k) {
		if (s == 1000000000) {
			ans.push_back(1);
		}
		else {
			ans.push_back(1000000000);
		}
	}
	rep(i, n) {
		if (i != n - 1) {
			cout << ans[i] << " ";
		}
		else {
			cout << ans[i] << endl;
		}
	}
	return 0;
}


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b < c+d){
        cout << "Right" << endl;
        return 0;
    }
    else if( a+b > c+d){
        cout << "Left" << endl;
        return 0;
    }
    else{
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
import sys,queue,math,numpy as np,scipy as sc
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in input().split()]
N,M = LI()
E = [LI() for _ in range(M)]
ans = 0
for i in range(M):
    g = [i for i in range(N+1)]

    def root(x):
        if g[x] != x:
            g[x] = root(g[x])
        return g[x]

    for j in range(M):
        if i != j: g[root(E[j][0])] = root(E[j][1])

    ans += (root(E[i][0]) != root(E[i][1]))

print (ans)

Measured memory_bytes: 13148
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    d = collections.deque()
    for i in range(n):
        if n % 2 == i % 2:
            d.append(a[i])
        else:
            d.appendleft(a[i])
    print(*d)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 91216
n = int(input())
h_s = [int(h) for h in input().split()]

ans = 0
count = 0
current = h_s[0]
for i in range(1, len(h_s)):
  prev = current
  current = h_s[i]
  #print(prev, current, count)
  if current <= prev:
    count += 1
  else:
    ans = max(ans, count)
    count = 0

ans = max(ans, count)    
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 112345
class UF{
public:
	int p[N], d[N], s[N];
	UF(){
		iota(p, p+N, 0);
		fill(d, d+N, 0);
		fill(s, s+N, 1);
	}

	int group(int a){
		if(p[a] == a) return a;
		else return p[a] = group(p[a]);
	}

	void merge(int a, int b){
		a = group(a);
		b = group(b);
		if(a == b) return;
		if(d[a] < d[b]) swap(a, b);
		p[b] = a;
		LAR(d[a], d[b] + 1);
		s[a] += s[b];
	}
} uf;

int ans[N] = {};

int main(){
	int n, m, k; scanf("%d%d%d", &n, &m, &k);
	REP(i, m){
		int a, b; scanf("%d%d", &a, &b);
		uf.merge(a, b);
		ans[a]--;
		ans[b]--;
	}
	REP(i, N) ans[i] += uf.s[uf.group(i)] - 1;
	REP(i, k){
		int a, b; scanf("%d%d", &a, &b);
		if(uf.group(a) != uf.group(b)) continue;
		ans[a]--;
		ans[b]--;
	}
	FOR(i, 1, n+1) printf("%d ", ans[i]);
}





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

int main(){
  int N,tgm=0;
  cin>>N;
  int a=N;
  for(int i=0; i<100; ++i){
    if(a>0){
      tgm+=a%10;
      a/=10;
    }
  }
  if(N%tgm==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256