akhauriyash/Code-Regression huggingface dataset:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    ans_list = []
    for i in range(n):
        a, b = i_map()
        if a == b:
            ans_list.append(1)
        else:
            ans_list.append(0)

    for i in range(n-2):
        if ans_list[i] == ans_list[i+1] == ans_list[i+2] == 1:
            print('Yes')
            exit()

    print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 72672
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include<cstdlib>
#include<map>
using namespace std;
int main(){
  string s1,s2;
  int n,cnt;
  while(cin >> cnt >> n && cnt||n){
    map<int,int>mp;
    int CNT = 0;
    while(mp.find(cnt) == mp.end()){
      mp.insert(make_pair(cnt,CNT));

      stringstream ss;
      ss << cnt;
      ss >> s1;
      string tmp;
      for(int i=s1.size();i<n;i++) tmp += "0";

      s1 = tmp + s1;
      s2 = s1;
      sort(s1.begin(),s1.end());
      sort(s2.rbegin(),s2.rend());

      cnt = atoi(s2.c_str()) - atoi(s1.c_str());
      CNT++;
    }
    cout << mp[cnt] << " " << cnt << " " << CNT-mp[cnt] << endl;
  }
}

Measured memory_bytes: 1256
#include <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <climits>
#include <numeric>

#define el '\n'
typedef long long ll;

using namespace std;



void sol(){
	
	int n,a,b;
	cin >>n;
	vector<pair<int ,int >> pii;
	bool sol = false;
	for (int i = 0; i < n; i++){
		cin >>a>>b;
		pii.push_back({a,b});
		if (a == b && i >= 2 && !sol){
			bool ok = true;
			for (int j = 1; j <=2; j++){
				ok &= (pii[i - j].first == 
				pii[i - j].second); 
			}
			if (ok){
				sol = 1;
			}
		}

	}
	if (sol)
		cout <<"Yes"<<el;
	else
	cout <<"No"<<el;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t = 1;
	while(t--){
	//	cout << t<<el;
		sol();
	}
}

Measured memory_bytes: 3124
import java.util.Scanner;

public class Main{
	static long a;
	static long b;
	static long x;
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int d = scan.nextInt();

		int[][] x = new int[n][d];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < d; j++) {
				x[i][j] = scan.nextInt();
			}
		}

		int ans = 0;
		for(int i = 0; i < n - 1; i++) {
			for(int j = i + 1; j < n; j++) {
				double temp = 0.0;
				for(int k = 0; k < d; k++) {
					temp += Math.pow((x[j][k] - x[i][k]), 2);
				}
				temp = Math.pow(temp, 0.5);
				if(temp - (long)temp == 0.0) {
					ans++;
				}
			}
		}
		System.out.println(ans);
	}
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long

#ifdef sarthak
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#else
#define trace(...)
#endif

#ifndef sarthak
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fort(i,v) for(auto i:v)
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) rep(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) rep(i,sizeof(ar)/sizeof(ar[0])) rep(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define sd2(x,y) scanf("%d %d",&x,&y)
#define slld2(x,y) scanf("%lld %lld",&x,&y)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pd2(x,y) printf("%d %d\n",x,y)
#define plld2(x,y) printf("%lld %lld\n",x,y)
#define all(ar) ar.begin(), ar.end()
#define endl '\n'
#define sz(x) (int)x.size()
#define len(x) (int)x.length()

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

void solve()
{
    ll arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin >> k;

    cout << arr[k-1] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed;
    cout << setprecision(10);
    #ifdef sarthak
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }

    #ifdef sarthak
    cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    #endif
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,c[501],s[501],f[501],i,j,ans;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<n;i++)cin>>c[i]>>s[i]>>f[i];
	for(i=1;i<n;i++)
	{
		ans=0;
		for(j=i;j<n;j++)
		{
			ans=max(ans,s[j]);
			if(ans%f[j]!=0)ans=ans+f[j]-(ans%f[j]);
			ans+=c[j];
		}
		cout<<ans<<endl;
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <tuple>
#include <iomanip>
#include <assert.h>

#define sqr(x) std::pow(x, 2.0)
#define INF 1e10
#define EPS 1e-10
#define REP(i, n) for (int i = 0; i < n; i++)
#define POS_OR_INF(x) (x > 0 ? x : INF)

using namespace std;

using ld = long double;
using ll = long long;

struct Point {
	Point() = default;
	Point(ld x, ld y) : x(x), y(y) {}
	Point(const Point& s, const Point& e) : x(e.x - s.x), y(e.y - s.y) {}

	Point normalized(void) const {
		return Point(x / norm(), y / norm());
	}

	ld norm(void) const {
		return sqrt(x * x + y * y);
	}

	Point flipped(void) const {
		return Point(-x, -y);
	}

	Point normal_vector(bool normalize = false) const {
		auto vec = Point(-y, x);
		return normalize ? vec.normalized() : vec;
	}

	ld theta(void) const {
		return atan2(y, x);
	}

	ld x, y;
};

using Vector = Point;

inline Vector points2vec(const Point& s, const Point& e) {
	return Vector(e.x - s.x, e.y - s.y);
}

inline ld distance(const Point& s, const Point& e) {
	return points2vec(s, e).norm();
}

inline ld distance_square(const Point& s, const Point& e) {
	return pow(points2vec(s, e).norm(), 2.0);
}

inline ld inner_product(const Point& p, const Point& q) {
	return p.x * q.x + p.y * q.y;
}

inline ld cross_product(const Point& p, const Point& q) {
	return p.x * q.y - p.y * q.x;
}

inline Vector operator * (const Vector& l, ld r) {
	return Vector(l.x * r, l.y * r);
}

inline Vector operator * (ld l, const Vector& r) {
	return r * l;
}

inline Vector operator / (const Vector& l, ld r) {
	return Vector(l.x / r, l.y / r);
}

inline Point operator + (const Point& l, const Point& r) {
	return Point(l.x + r.x, l.y + r.y);
}

inline Point operator - (const Point& l, const Point& r) {
	return Point(l.x - r.x, l.y - r.y);
}

inline istream& operator >> (istream& is, Point& p) {
	return is >> p.x >> p.y;
}

template <typename T>
inline T min4(T x1, T x2, T x3, T x4) {
	return min(min(x1, x2), min(x3, x4));
}

template <typename T>
inline T max4(T x1, T x2, T x3, T x4) {
	return max(max(x1, x2), max(x3, x4));
}


int main(int argc, char** argv) {
	int N, K;

	cout << fixed << setprecision(20);
	cin >> N >> K;

	vector<ll> x(N), y(N);

	REP(i, N) cin >> x[i] >> y[i];

	ll best = numeric_limits<ll>::max();

	REP(h, N) {
		REP(i, N) {
			REP(j, N) {
				REP(k, N) {
					auto l = min4(x[h], x[i], x[j], x[k]);
					auto t = min4(y[h], y[i], y[j], y[k]);
					auto r = max4(x[h], x[i], x[j], x[k]);
					auto b = max4(y[h], y[i], y[j], y[k]);

					int n = 0;
					REP(m, N)
						n += x[m] >= l && x[m] <= r && y[m] >= t && y[m] <= b;

					if (n >= K)
						best = min(best, (r - l) * (b - t));
				}
			}
		}
	}
	cout << best << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  if(n == 1) {
    if(m == 1) {
      cout << 1 << endl;
    } else {
      cout << m - 2 << endl;
    }
  } else {
    if(m == 1) {
      cout << n - 2 << endl;
    } else {
      cout << (n - 2) * (m - 2) << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct card{
	char c;
 	int i;
 };
 card l[100000];
card r[100000];
void merge(int n,card H[],int left,int mid,int right){
	int n1 = mid-left;
	int n2 = right -mid;
	for(int i = 0;i<n1;i++) l[i] = H[left+i];
	for(int i = 0;i<n2;i++) r[i] = H[mid+i];
	l[n1].i = r[n2].i = 99;
	int i = 0,j = 0;
	for(int k = left;k<right;k++){
		if(l[i].i <=r[j].i){
			H[k] = l[i];
			i++;
		}else{
			H[k] = r[j];
			j++;
		}
	}
}
void mergesort(card H[],int n,int left,int right){
	if(left +1<right){
	int mid = (left + right)/2;
	mergesort(H,n,left,mid);
	mergesort(H,n,mid,right);
	merge(n,H,left,mid,right);
	}
}
int partition(card A[],int p,int r){
		int i = p;
	for(int j = p;j<r;j++){
		if(A[r].i >= A[j].i){
			swap(A[j],A[i]);
			i++;
		}
	}
	swap(A[i],A[r]);

	return i;
}
int quicksort(card A[],int p,int r){
	
	if(p<r){
	int q = partition(A,p,r);
	quicksort(A,p,q-1);
	quicksort(A,q+1,r);
	}
}
int main(){
	int n;
	cin>>n;
	card A[n];
	card H[n];
	for(int i = 0;i<n;i++)cin>>A[i].c>>A[i].i ,H[i] = A[i];
	quicksort(A,0,n-1);
	mergesort(H,n,0,n);
	for(int i = 0;i<n;i++){
		if(H[i].c != A[i].c){
			cout<<"Not stable"<<endl;
			break;
		}
		if(i == n-1){
			cout<<"Stable"<<endl;
		}

	}
	for(int i = 0;i<n;i++){
		cout<<A[i].c<<" "<<A[i].i<<endl;
	}
}


Measured memory_bytes: 5412
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
ll n, s;
vector<ll> a;
ll memo[3300][3300];
ll mod = 998244353;
ll rec(ll i, ll j){
    if(i == -1 && j == 0){
        return 1;
    }
    if(i == -1){
        return 0;
    }

    if(memo[i][j] != -1) return memo[i][j];

    ll res = 0;
    if(j - a[i] >= 0) res = rec(i - 1, j - a[i]);
    res %= mod;
    res += rec(i - 1, j);
    res %= mod;
    res += rec(i - 1, j);
    res %= mod;
    
    return memo[i][j] = res;
}
int main(void){
    cin >> n >> s;
    a.resize(n);
    rep(i, n) cin >> a[i];

    rep(i, 3300){
        rep(j, 3300){
            memo[i][j] = -1;
        }
    }

    cout << rec(n - 1, s) << endl;
}


Measured memory_bytes: 88888
#include <stdio.h>

int main (void){
  
  int K, S;
  
  scanf("%d %d", &K, &S);
  
  int X,Y,Z;
  int count=0;
  
  for (X=0; X<=K; X++){
   for (Y=0; Y<=K; Y++){
       if (0<=S-X-Y && S-X-Y<=K) {count=count+1;}
   }
  }
  
  printf("%d", count);
  
  return 0;
}

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

long long cnt = 0;
int l;
int A[1000000];
int n;
vector<int> G;

// 指定间隔g的插入排序
void insertionSort(int A[], int n, int g)
{
    for (int i = g; i < n; i++)
    {
        int v = A[i];
        int j;
        for (j = i - g; j >= 0 && A[j] > v; j -= g)
        {
            A[j + g] = A[j];
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n)
{
    // generate G serise G = {1,4 ,13, 40, 121, 364,1093}
    for (int h = 1;;)
    {
        if (h > n)
        {
            break;
        }
        G.push_back(h);
        h = 3 * h - 1;
    }

    for (int i = G.size() - 1; i >= 0; i--) // 按逆序指定G[i] = g;
    {
        insertionSort(A, n, G[i]);
    }
}

int main()
{
    // cin >> n;
    // // use faster scanf function to input
    // for (int i = 0; i < n; i++)
    // {
    //     // scanf("%d", &A[i]);
    //     cin >> A[i];
    // }

    // shellSort(A, n);

    // cout << G.size() << endl;
    // for (int i = G.size() - 1; i >= 0; i++)
    // {
    //     // printf("%d", G[i]);

    //     if (i != G.size() - 1)
    //     {
    //         // printf(" ");
    //         cout << " ";
    //     }
    //     cout << G[i];
    // }
    // // printf("\n");
    // cout << endl;
    // // printf("%d\n", cnt);
    // cout << cnt << endl;
    // for (int i = 0; i < n; i++)
    // {
    //     // printf("%d\n", A[i]);
    //     cout << A[i] << endl;
    // }

    // return 0;

    cin >> n;
    // use faster scanf function to input
    for (int i = 0; i < n; i++)
    {
        // scanf("%d", &A[i]);
        cin >> A[i];
    }

	shellSort(A,n);

	cout << G.size() << "\n";
	for (int i = G.size() - 1; i >= 0; --i)
	{
		if (i != G.size() - 1)
		{
			cout << " ";
		}
		cout << G[i];
	}
	cout << "\n";

	cout << cnt << "\n";

	for (int i = 0; i < n; ++i)
	{
		cout << A[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 6968
#include <iostream>
#include <algorithm>
#include <cmath>
#define rep(i, a, n) for(int i = a;i < n;i++)
#define repr(i, a, n) for(int i = a;i > n;i--)
using namespace std;


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

	cout << n / 3 << endl;

	return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    ll ans = N-K;
    rep(i,N){
        cin >> H[i];
        H[i]--;
    }
    sort(H.begin(), H.end());
    rep(i,N-K) ans += H[i];
    if(ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
class UnionFindVerSize():
    def __init__(self, N):
        """ N個のノードのUnion-Find木を作成する """
        # 親の番号を格納する。自分が親だった場合は、自分の番号になり、それがそのグループの番号になる
        self._parent = [n for n in range(0, N)]
        # グループのサイズ（個数）
        self._size = [1] * N

    def find_root(self, x):
        """ xの木の根(xがどのグループか)を求める """
        if self._parent[x] == x: return x
        self._parent[x] = self.find_root(self._parent[x]) # 縮約
        return self._parent[x]

    def unite(self, x, y):
        """ xとyの属するグループを併合する """
        gx = self.find_root(x)
        gy = self.find_root(y)
        if gx == gy: return

        # 小さい方を大きい方に併合させる（木の偏りが減るので）
        if self._size[gx] < self._size[gy]:
            self._parent[gx] = gy
            self._size[gy] += self._size[gx]
        else:
            self._parent[gy] = gx
            self._size[gx] += self._size[gy]

    def get_size(self, x):
        """ xが属するグループのサイズ（個数）を返す """
        return self._size[self.find_root(x)]

    def is_same_group(self, x, y):
        """ xとyが同じ集合に属するか否か """
        return self.find_root(x) == self.find_root(y)

    def calc_group_num(self):
        """ グループ数を計算して返す """
        N = len(self._parent)
        ans = 0
        for i in range(N):
            if self.find_root(i) == i:
                ans += 1
        return ans

n, m = map(int, input().split())
plist=list(map(int, input().split()))
uf = UnionFindVerSize(n)
#print(tlist)
for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x-1, y-1)
kotae=0
for i in range(n):
    if uf.is_same_group(i, plist[i]-1):
        kotae+=1
print(kotae)

Measured memory_bytes: 90220
#include <stdio.h>
#include <math.h>

#define N  10000

void isprime(int);
int count=0;

int main(){
  int i,j,n,key;
  int A[N];

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++){
    scanf("%d",&A[i]);
    
  }
  for(i = 1 ; i < n ; i++){
    key = A[i];
    j = i -1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
  }
  isprime(A[0]);
  for(i=1;i<n;i++){
    if(A[i] != A[i-1]){
      isprime(A[i]);
    }
  }
  printf("%d\n",count);
  return 0;
}

void isprime(int x){
  int i,j=0;
  if(x!=1){
    for(i=2;i<= sqrt(x);i++){

      if(x%i==0)j++;

    }
    if(j==0)count++;
  }
  else ;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
using ll = long long;
struct dsu {
    public:
	dsu() : _n(0) {}
	dsu(int n) : _n(n), parent_or_size(n, -1) {}

	int merge(int a, int b) {
		assert(0 <= a && a < _n);
		assert(0 <= b && b < _n);
		int x = leader(a), y = leader(b);
		if (x == y) return x;
		if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
		parent_or_size[x] += parent_or_size[y];
		parent_or_size[y] = x;
		return x;
	}

	bool same(int a, int b) {
		assert(0 <= a && a < _n);
		assert(0 <= b && b < _n);
		return leader(a) == leader(b);
	}

	int leader(int a) {
		assert(0 <= a && a < _n);
		if (parent_or_size[a] < 0) return a;
		return parent_or_size[a] = leader(parent_or_size[a]);
	}

	int size(int a) {
		assert(0 <= a && a < _n);
		return -parent_or_size[leader(a)];
	}

	std::vector<std::vector<int>> groups() {
		std::vector<int> leader_buf(_n), group_size(_n);
		for (int i = 0; i < _n; i++) {
			leader_buf[i] = leader(i);
			group_size[leader_buf[i]]++;
		}
		std::vector<std::vector<int>> result(_n);
		for (int i = 0; i < _n; i++) { result[i].reserve(group_size[i]); }
		for (int i = 0; i < _n; i++) { result[leader_buf[i]].push_back(i); }
		result.erase(
		    std::remove_if(result.begin(), result.end(), [&](const std::vector<int>& v) { return v.empty(); }),
		    result.end());
		return result;
	}

    private:
	int _n;
	// root node: -1 * component size
	// otherwise: parent
	std::vector<int> parent_or_size;
};
int main() {
	int n;
	cin >> n;
	dsu tree(n);
	int q;
	cin >> q;
	while (q--) {
		int t, u, v;
		cin >> t >> u >> v;
		if (t == 0) {
			tree.merge(u, v);
		} else {
			if (tree.same(u, v))
				cout << 1 << endl;
			else
				cout << 0 << endl;
		}
	}
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}
 
void solve() {
    int n;
    cin >> n;
    vector<vector<int>> dp(n + 1, vector<int>(3, 0));
    int a, b, c;
    REP(i, n) {
        cin >> a >> b >> c;
        dp[i + 1][0] = a + max(dp[i][1], dp[i][2]);
        dp[i + 1][1] = b + max(dp[i][0], dp[i][2]);
        dp[i + 1][2] = c + max(dp[i][0], dp[i][1]);
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << EOL;
}


Measured memory_bytes: 5760
a,b,c = input().split()
a_left=a[0]
a_right=a[-1]
b_left=b[0]
b_right=b[-1]
c_left=c[0]
c_right=c[-1]
if a_right == b_left and b_right == c_left:
  print("YES")
else:
  print("NO")

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

#define FOR(i, a, b) for(int(i)=(a);(i)<(b);(i)++)
#define REP(i, n) FOR((i), 0, (n))

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);

	int n, ma, mb;
	cin>>n>>ma>>mb;
	vector<int> a(n), b(n), c(n);
	REP(i, n){
		cin>>a[i]>>b[i]>>c[i];
	}
	
	int dp[n][10*n+1][10*n+1];
	REP(i, n){
		REP(j, 10*n+1){
			REP(k, 10*n+1){
				dp[i][j][k]=INF;
			}
		}
	}
	dp[0][0][0]=0;
	dp[0][a[0]][b[0]]=c[0];

	FOR(i, 1, n){
		REP(j, 10*n+1){
			REP(k, 10*n+1){
				if(j-a[i]>=0 && k-b[i]>=0){
					dp[i][j][k]=min(dp[i-1][j][k], dp[i-1][j-a[i]][k-b[i]]+c[i]);
				}else{
					dp[i][j][k]=dp[i-1][j][k];
				}
			}
		}
	}

	int ans=INF, k=1;
	while(k*ma<10*n+1 && k*mb<10*n+1){
		if(ans>dp[n-1][k*ma][k*mb]){
			ans=dp[n-1][k*ma][k*mb];
		}
		k++;
	}

	if(ans==INF){
		cout<<-1<<endl;
	}else{
		cout<<ans<<endl;
	}

	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    int K;
    cin >> K;
    ll ans = 0;
    for (int i = 1; i < K + 1; i++)
    {
        for (int j = 1; j < K + 1; j++)
        {
            for (int k = 1; k < K + 1; k++)
            {
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }

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


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ri(x) scanf("%d",&(x))
#define ri2(x,y) scanf("%d %d",&(x),&(y))
#define ri3(x,y,z) scanf("%d %d %d",&(x),&(y),&(z))
#define rll(x) scanf("%lld",&(x))
#define rll2(x,y) scanf("%lld %lld",&(x),&(y))
#define rll3(x,y,z) scanf("%lld %lld %lld",&(x),&(y),&(z))
#define gc(x) ((x) = getchar())
using namespace::std;

const long double PI = acos(-1);
const long long MOD = 1000000000 +7;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> tll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<tll> vtll;
typedef vector<string> vs;
typedef set<int> si;
typedef set<ii> sii;
typedef set<iii> siii;

ll gcd(ll a, ll b){ return b==0?a:gcd(b,a%b);}

ll add(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a+b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll mul(ll a, ll b, ll m = MOD){
	if(a >= m) a %= m;
	if(b >= m) b %= m;
	if(a < 0) a += m;
	if(b < 0) b += m;
	ll res = a*b;
	if(res >= m or res <= -m) res %= m;
	if(res < 0) res += m;
	return res;
}

ll pow_mod(ll a, ll b, ll m = MOD){
	ll res = 1LL;
	a = a%m;
	while(b){
		if(b&1) res = mul(res,a,m);
		b >>= 1;
		a = mul(a,a,m);
	}
	return res;
}

ll fastexp(ll a, ll b){
	ll res = 1LL;
	while(b){
		if(b&1) res = res*a;
		b >>= 1;
		a *= a;
	}
	return res;
}

int gcdExtendido(int a, int b, int *x, int *y){
	if(a == 0){
		*x = 0;
		*y = 1;
		return b;
	}
	int x1, y1;
	int gcd = gcdExtendido(b%a,a,&x1,&y1);
	
	*x = y1-(b/a)*x1;
	*y = x1;
	return gcd;
}

int modInverso(int a, int m){
	int x, y;
	int g = gcdExtendido(a,m,&x,&y);
	if(g!=1) return -1;
	else return (x%m + m)%m;
}

/****************************************
*************P*L*A*N*T*I*L*L*A************
*****************************************/

const int N = 100000+5;
const int E = 3;

ll L;
int n;
char s[N];
bool leaf[N];
int nodos = 1;
int trie[N][E];

void insert(){
	int pos = 0;
	for(int i=0; i<strlen(s); i++){
		int nxt = s[i] - '0';
		if(trie[pos][nxt] == 0){
			trie[pos][nxt] = nodos++;
		}
		pos = trie[pos][nxt];
	}
	leaf[pos] = true;
}

ll getGrundy(int u, int depth){
	if(leaf[u]) return 0LL;
	ll ans = 0;
	for(int i=0; i<2; i++){
		if(trie[u][i]){
			ans ^= getGrundy(trie[u][i],depth+1);
		}
		else{
			ll h = L - depth;
			ll G = (-h) & h;
			ans ^= G;
		}
	}
	return ans;
}

int main(){
	ri(n);
	rll(L);
	for(int i=0; i<n; i++){
		scanf("%s",s);
		insert();
	}
	ll grundy = getGrundy(0,0);
	puts(grundy?"Alice": "Bob");
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define endk '\n'

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < n-2; i++)
    if ((s[i] == 'A') && (s[i+1] == 'B') && (s[i+2] == 'C')) {
      ans++;
      i+= 2;
    }
  cout << ans << endk;
  return 0;}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int n,k; cin >> n >> k;
    vector<int> a(n);
    for(int i = 0;i < n;i ++) cin >> a.at(i);

    vector<int> b(n+1);
    for(int i = 0;i < n;i ++){
        b.at(a.at(i)) ++;
    }
    int count = 0;
    for(int i = 0;i < n+1;i ++){
        if(b.at(i)) count ++;
    }

    if(count <= k){
        cout << 0 << endl;
        return 0;
    }

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

    int ans = 0;
    for(int i = 0;count > k;i ++){
        ans += b.at(i);
        if(b.at(i)) count --;
    }

    cout << ans << endl;


}



Measured memory_bytes: 3456
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++){
			h[i] = sc.nextInt();
		}
		int max = h[n-1];
		boolean flag = true;
		for(int i = n-2; i >= 0; i--){
			if(h[i] > max){
				if(h[i]-1 > max){
					flag = false;
					break;
				}
			}else if(h[i] < max){
				max = h[i];
			}
		}
		System.out.print(flag?"Yes":"No");
	}
}


Measured memory_bytes: 50268
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        String T = sc.next();
        char s[] = S.toCharArray();
        char t[] = T.toCharArray();
        
        for(int i=0; i<N; i++) {
            System.out.print(s[i]);
            System.out.print(t[i]);
        }
    }
}

Measured memory_bytes: 35596
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std ;

struct P{
	int Num ;
	string str ;
};

int N ;
char M ;

bool Compare(const P& F , const P& S){ return ( (F.Num>=S.Num)?((F.Num==S.Num)?(F.str<S.str):1):(F.Num>=S.Num) ) ; }

void Solve(){
	int cnt = 0 ;
	bool b ;
	vector<P> V ;
	string S ;
	P Check ;
	
	cin.ignore() ;
	for( int i=0 ; i<N ; i++ ){
		getline( cin , S ) ;
		
		int f = 0 ;
		for( int j=0 ; j<=S.size() ; j++ ){
			if( !( 'a' <= S[j] && S[j] <= 'z' ) || j == S.size() ){
				Check.Num = 1 ;
				Check.str = S.substr(f,j-f) ;
				b = true ;
				for( int i=0 ; b && i<V.size() ; i++ ){
					if( V[i].str == Check.str ){
						V[i].Num += 1 ;
						b = false ;
					}
				}
				if( b ) V.push_back( Check ) ;
				f = j+1 ;
			}
		}
	}
	
	sort( V.begin() , V.end() , Compare ) ;
	
	//for( int i=0 ; i<V.size() ; i++ ) cout << V[i].Num << " " << V[i].str << endl ;
	
	cin >> M ;
	
	int p = 0 ;
	for( int i=0 ; i<V.size() ; i++ ){
		if( M == V[i].str[0] && p < 5 ){
			cout << ( p++ ?" " :"") << V[i].str ;
		}
	}
	if( p==0 ) cout << "NA" ;
	cout << endl ;
}

int main(){
	
	while( cin >> N , N ){
		Solve() ;
	}
	
}

Measured memory_bytes: 1220
#include <iostream>
#include <utility>
#include <map>
using namespace std;
 
#define MAX_N   (200001)
 
int N, K, L;
int k[MAX_N];
int rank_k[MAX_N];
int l[MAX_N];
int rank_l[MAX_N];
 
void init() {
    for (int i = 1; i <= N; i++) {
        k[i] = i;
        rank_k[i] = 0;
        l[i] = i;
        rank_l[i] = 0;
    }
}
 
int find_k(int x) {
    if (k[x] == x) {
        return x;
    } else {
        return k[x] = find_k(k[x]);
    }
}
 
int find_l(int x) {
    if (l[x] == x) {
        return x;
    } else {
        return l[x] = find_l(l[x]);
    }
}
 
void unite_k(int x, int y) {
    x = find_k(x);
    y = find_k(y);
    
    if (x == y) {
        return;
    }
    
    if (rank_k[x] < rank_k[y]) {
        k[x] = y;
    } else {
        k[y] = x;
        if (rank_k[x] == rank_k[y]) {
            rank_k[x]++;
        }
    }
}
 
void unite_l(int x, int y) {
    x = find_l(x);
    y = find_l(y);
    
    if (x == y) {
        return;
    }
    
    if (rank_l[x] < rank_l[y]) {
        l[x] = y;
    } else {
        l[y] = x;
        if (rank_l[x] == rank_l[y]) {
            rank_l[x]++;
        }
    }
}
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /* N, K, Lの取得 */
    cin >> N >> K >> L;
    
    /* 初期化 */
    init();
    
    /* 道路で連結されているものの取得 */
    for (int i = 0; i < K; i++) {
        int p, q;
        cin >> p >> q;
        unite_k(p, q);
    }
    
    /* 鉄道で連結されているものの取得 */
    for (int i = 0; i < L; i++) {
        int r, s;
        cin >> r >> s;
        unite_l(r, s);
    }
    
    /* 結果の出力 */
    map<pair<int, int>, int> cnt;
    for (int i = 1; i <= N; i++) {
        cnt[make_pair(find_k(i), find_l(i))]++;
    }
    for (int i = 1; i <= N; i++) {
        cout << cnt[make_pair(find_k(i), find_l(i))] << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 15232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll ans = 0;
ll N;
vector<l_l> v;
ll Rmin[100050];
ll LLeft[100050], RLeft[100050], LRight[100050], RRight[100050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    v.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> v[i].first >> v[i].second;
        //chmax(ans, v[i].second - v[i].first + 1);
        //v[i].second *= -1;
    }
    LLeft[0] = v[0].first;
    RLeft[0] = v[0].second;
    for(int i = 1; i <= N - 1; i++) {
        LLeft[i] = max(LLeft[i-1], v[i].first);
        RLeft[i] = min(RLeft[i-1], v[i].second);
    }
    LRight[N] = 0;
    RRight[N] = 2e9;
    for(int i = N - 1; i >= 0; i--) {
        LRight[i] = max(LRight[i+1], v[i].first);
        RRight[i] = min(RRight[i+1], v[i].second);
    }
    for(int i = 0; i <= N - 1; i++) {
        ll nowans = v[i].second - v[i].first + 1;
        ll Rmin = 2e9;
        ll Lmax = 0;
        if(i > 0) {
            chmin(Rmin, RLeft[i-1]);
            chmax(Lmax, LLeft[i-1]);
        }
        if(i < N - 1) {
            chmin(Rmin, RRight[i+1]);
            chmax(Lmax, LRight[i+1]);
        }
        nowans += max(Rmin - Lmax + 1, 0LL);
        chmax(ans, nowans);
    }
    for(int i = 0; i < N; i++) {
        v[i].second *= -1;
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < N; i++) {
        v[i].second *= -1;
    }
    Rmin[N] = 1e9;
    for(int i = N - 1; i >= 0; i--) {
        Rmin[i] = min(Rmin[i+1], v[i].second);
    }
    set<ll> st;
    st.insert(2e9);
    for(int i = 0; i < N - 1; i++) {
        //cerr << "---" << i << "---" << endl;
        st.insert(v[i].second);
        //auto itr = st.upper_bound(Rmin[i+1]);
        auto itr = st.begin();
        //cerr << Rmin[i+1] << endl;
        if(itr != st.begin()) itr--;
        //cerr << *itr << endl;
        ll nowans = max(*itr - v[i].first + 1, 0LL);
        ll subans = 0;
        subans = Rmin[i+1];
        /*
        if(itr != st.end()) {
            itr++;
            if(itr != st.end()) {
                chmin(subans, *itr);
            }
        }
        */
        //cerr << subans << endl;
        //cerr << nowans << " " << subans << endl;
        subans -= v.back().first;
        subans++;
        chmax(subans, 0LL);
        //cerr << nowans << " " << subans << endl;
        chmax(ans, nowans + subans);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        int Q; cin >> Q;
        vector<vector<int> > f(M, vector<int>(N, true)), dp(M, vector<int>(N));
        dp[0][0] = 1;
        for (int i = 0; i < Q; i++) {
            int x, y; cin >> x >> y;
            f[y-1][x-1] = false;
        }

        for (int i = 0; i < M; i++) {
            for (int j = 0; j < N; j++) {
                if (i + 1 < M && f[i+1][j]) dp[i+1][j] += dp[i][j];
                if (j + 1 < N && f[i][j+1]) dp[i][j+1] += dp[i][j];
            }
        }

        cout << dp[M-1][N-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3104
N, M = map(int, input().split())
AB = [[] for i in range(N)]
for i in range(N):
    AB[i] = list(map(int, input().split()))

AB = sorted(AB)

remain_drink = M
price = 0
i = 0
while remain_drink > 0:
    if AB[i][1] <= remain_drink:
        price += AB[i][0] * AB[i][1]
        remain_drink -= AB[i][1]
    else:
        price += AB[i][0] * remain_drink
        remain_drink = 0
    i += 1
print(price)



Measured memory_bytes: 28624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;

int main() {
    int A,B;
    cin>>A>>B;
    if(A>0&&A<10&&B>0&&B<10){
        cout<<A*B<<endl;
    }else{
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
h, w = gets.chomp.split(" ").map(&:to_i)
s = []
s << ("." * (w+2)).split("")
h.times do
  tmp = gets.chomp.split("")
  tmp.push(".")
  tmp.unshift(".")
  s << tmp
end
s << ("." * (w+2)).split("")

t = Array.new(h).map{Array.new(w)}

for i in 1..h do
  for j in 1..w do
    if s[i][j] == "#"
      t[i-1][j-1] = "#"
    else
      str = s[i-1][j-1] + s[i-1][j] + s[i-1][j+1] + s[i][j-1] + s[i][j+1] + s[i+1][j-1] + s[i+1][j] + s[i+1][j+1]
      t[i-1][j-1] = str.chars.count {|v| v == "#"}
    end
  end
end

h.times do |i|
  puts t[i].join
end


Measured memory_bytes: 2172
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> as(N);
  for (auto i = 0; i < N; i++)
    cin >> as[i];

  ll res = 0;
  for (auto i = 0; i < N; i++)
  {
    bool prime = true;
    for (auto j = 2; j * j <= as[i]; j++)
    {
      if (as[i] % j == 0) {
        prime = false;
        break;
      }
    }
    if (prime) res++;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 3132
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
const int maxn=1e5+10;
   int n,k;
int a[maxn];
int sum[maxn];

int  slove(int n)
{
    int sum=0;
    int couts=0;
    for(int i=n;;i=i*2)
    {

        sum=i;
        couts++;
        if(sum>=k)
        break;
       // cout<<sum<<' ';
    }
   // cout<<couts-1<<endl;
    return couts;
}
double pows(double a,int b)
{
    double re=1.0;
    while(b)
    {
        if(b&1)
        re=re*a;
         a=a*a;
        b/=2;
    }
    return re;
}
int main()
{

       cin>>n>>k;
       for(int i=1;i<=n;i++)
        {
           a[i]=slove(i);
        }
        double ans=0;
        for(int i=1;i<=n;i++)
        {
            ans+=pows(0.5,a[i]);
        }
        ans=2*ans/n;
        printf("%.12f\n",ans);

return 0;
    }


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

int main(){
    int N;
    cin >> N;
    bool F[N][10];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    int P[N][11];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++){
            cin >> P[i][j];
        }
    }
    int ans = int(-1e9);
    for(int i = 1; i < 1024; i++){
        int bits[10];
        int tmp_i = i;
        for(int j = 0; j < 10; j++){
            bits[j] = tmp_i % 2;
            tmp_i /= 2;
        }
        int profit = 0;
        for(int j = 0; j < N; j++){
            int count = 0;
            for(int k = 0; k < 10; k++){
                if(F[j][k] && bits[k]){
                    count++;
                }
            }
            profit += P[j][count];
        }
        ans = max(ans, profit);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl


signed main(){
    int A,B,Q;
    int s[114514],t[114514],x[114514];
    cin >> A >> B >> Q;
    REP(i,A){cin >> s[i+1];}s[0]=-INF;s[A+1]=INF;
    REP(i,B){cin >> t[i+1];}t[0]=-INF;t[B+1]=INF;
    REP(i,Q){cin >> x[i];}
    
    int ok,ng,mid1,mid2;
    A+=2;B+=2;
    
    int Ans;
    REP(i,Q){
        
        ok=A,ng=0;
        while(abs(ok-ng)>1){
            mid1=(ok+ng)/2;
            if(x[i]<s[mid1]){
                ok=mid1;
            }else{
                ng=mid1;
            }
        }
        
        ok=B,ng=0;
        while(abs(ok-ng)>1){
            mid2=(ok+ng)/2;
            if(x[i]<t[mid2]){
                ok=mid2;
            }else{
                ng=mid2;
            }
        }
        
        
        Ans=INF;
        for(int j=-1;j<=1;j++){
            for(int k=-1;k<=1;k++){
                int X=x[i],S=s[mid1-j],T=t[mid2-k];
                Ans=min(Ans,abs(X-S)+abs(S-T));
                Ans=min(Ans,abs(X-T)+abs(S-T));
            }
        }
        
        
        cout << Ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
 
using namespace std;
 
int main (void) {
  int t1, t2, t3, t4, tt;
  int x, y;
   
  cin >> t1 >> t2 >> t3 >> t4;
 
  tt = t1 + t2 + t3 + t4;
 
  cout << tt/60 << endl << tt  - (tt/60)*60 << endl;
 
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define gc getchar
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define x1 uvuvwevwevwe
#define y1 onyetenyevwe
#define x2 ugwemubwem
#define y2 ossas
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
template <typename T> void scan(T &angka){
	angka=0;char input=gc();T kali=1;
	while(!(48<=input&&input<=57)){	if(input=='-')	kali=-1;input=gc();}
	while(48<=input&&input<=57)	angka=(angka<<3)+(angka<<1)+input-48,input=gc();angka*=kali;
}
template <typename T1,typename T2> void scan(T1 &angka1,T2 &angka2){
	scan(angka1);scan(angka2);
}
int n;
vector <pair<LL,LL> >daftar[3];
LL ans=0;
void gabung(vector <pair<LL,LL> > tadi,vector <pair<LL,LL> > &baru){
	int idx=0;
	LL temp=0;
	for(int i=0;i<n;i++)
	{
		while(idx<n&&tadi[idx].fi<baru[i].fi)
			temp+=tadi[idx++].se;
		baru[i].se=temp;
	}
}
int main()
{
	scan(n);
	for(int ulang=0;ulang<3;ulang++)
	{
		daftar[ulang].resize(n);
		for(int i=0;i<n;i++)
		{
			scan(daftar[ulang][i].fi);
			daftar[ulang][i].se=1;
		}
		sort(all(daftar[ulang]));
	}
	gabung(daftar[0],daftar[1]);
	gabung(daftar[1],daftar[2]);
	for(int i=0;i<n;i++)
		ans+=daftar[2][i].se;
	cout<<ans<<endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h> 
using namespace std;
 
int main(){
  char enki;
  cin >> enki;
  if (enki=='A') cout << 'T' << endl;
  if (enki=='T') cout << 'A' << endl;
  if (enki=='C') cout << 'G' << endl;
  if (enki=='G') cout << 'C' << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n,a,b;
	cin >> n >> a >> b;
	long long ans=0;
	int prex;
	for(long long  i=0;i<n;i++){
		int x;
		cin >> x;
		if(i!=0){
			if(a*(x-prex)>b) ans+=b;
			else ans+=a*(x-prex);
		}
		prex=x;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP1(i,a,b) for (int i = a; i <= (int)(b); i++)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template <class T, class F = less<T>>
void sort_uniq(vector<T> &v, F f = F()) {
    sort(begin(v), end(v), f);
    v.resize(unique(begin(v), end(v)) - begin(v));
}

const int N=1e6,M=11;
bool ok[M];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    REP(i,k) {
        int d;
        cin >> d;
        ok[d]=1;
    }
    for ( int i=n; i<N; i++ ) {
        int j=i;
        bool f=1;
        while ( j ) {
            int d=j%10;
            if ( ok[d] ) {
                f=0;
                break;
            }
            j/=10;
        }
        if ( f ) {
            cout << i << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 

int main() {
    int n;
    cin >> n;
    unordered_set<int> st; 
    rep(i, n) {
        int a;cin >> a;
        if(st.count(a)) st.erase(a);
        else st.insert(a);
    }
    cout << st.size() << endl;
    return 0;
}

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

using namespace std;

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

int ret[200020];
int dp[200020];
int a[200020];
vector<int> d[200020];
int n;

void dfs(int x, int p, int l){
  auto lo = lower_bound(dp, dp + l, a[x]);
  int b = *lo;
  if(lo == dp + l){
    ret[x] = l + 1;
  }else{
    ret[x] = l;
  }
  *lo = a[x];
  for(auto y: d[x]) if(y != p){
    dfs(y, x, ret[x]);
  }
  *lo = b;
}

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  REP(i, n - 1){
    int x, y;
    cin >> x >> y;
    --x, --y;
    d[x].push_back(y);
    d[y].push_back(x);
  }
  REP(i, n + 1){
    dp[i] = 1 << 30;
  }
  dfs(0, -1, 0);
  REP(i, n){
    cout << ret[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 31072