akhauriyash/Code-Regression huggingface dataset:
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;

int main() {
	int A, B, C; cin >> A >> B >> C;
	int init = A % B;
	if (init == C) {
		cout << "YES" << endl;
		return 0;
	}
	int left = A * 2;
	int mod = left % B;
	while (mod != init) {
		if (mod == C) {
			cout << "YES" << endl;
			return 0;
		}
		left += A;
		mod = left % B;
	}
	cout << "NO" << endl;
}



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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
#define pow10(n) int(1e##n + n)

void solve()
{
    // 2回以上出る数についてのみ考えると,
    // 操作は「出現が2回目となる数」集合から2枚選んで捨てることと等価とわかる
    // したがって, 答えは
    // (種類数) - |出現が2回目以降となる数|%2

    map<int, int> mp;
    int N;
    cin >> N;
    REP0 (i, N)
    {
        int A;
        cin >> A;
        mp[A]++;
    }

    int kind = 0;
    int num_2nds = 0;
    for (auto p : mp)
    {
        kind++;
        num_2nds += (p.second - 1);
    }
    std::cout << kind - (num_2nds % 2) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>
double dat[100][100];
double dp[200][100];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++){
			for(int j=0;j<a;j++){
				scanf("%lf",&dat[i][j]);
			}
		}
		for(int i=0;i<a;i++)dp[0][i]=1;
		for(int i=1;i<b;i++){
			for(int j=0;j<a;j++){
				double max=0;
				for(int k=0;k<a;k++){
					if(max<dp[i-1][k]*dat[k][j])max=dp[i-1][k]*dat[k][j];
				}
				dp[i][j]=max;
			}
		}
		double ret=0;
		for(int i=0;i<a;i++){
			if(ret<dp[b-1][i])ret=dp[b-1][i];
		}
		printf("%.2lf\n",ret);
	}
}

Measured memory_bytes: 0
N, M = gets.split.map(&:to_i)
sports = []
voters = []
score = Array.new(N,0)

N.times do
  sports << gets.strip.to_i
end

M.times do
  voters << gets.strip.to_i
end

voters.each do |voter|
  sports.each do |sport|
  	if sport <= voter
  	  score[sports.find_index { |n| n == sport }] += 1
  	  break
  	end
  end
end

p score.find_index{ |n| n == score.max.to_i} + 1

Measured memory_bytes: 8788
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll a,b;
  cin >> a >> b;
  cout << ceil(a,b) << endl;
  return 0;
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<long long> a(3 * N);
	for (auto &a_i : a) cin >> a_i;

	vector<long long> large(3 * N);
	priority_queue<long long, vector<long long>, greater<void>> q;

	for (int i = 0; i < N; ++i) {
		q.push(a[i]);
		if (i == 0) {
			large[i] = a[i];
		}
		else {
			large[i] = large[i - 1] + a[i];
		}
	}
	for (int i = N; i < 2 * N; ++i) {
		if (a[i] > q.top()) {
			large[i] = large[i - 1] - q.top() + a[i];
			q.pop();
			q.push(a[i]);
		}
		else {
			large[i] = large[i - 1];
		}
	}

	vector<long long> small(3 * N);
	priority_queue<long long> r;
	for (int i = 3 * N - 1; i >= 2 * N; --i) {
		r.push(a[i]);
		if (i == 3 * N - 1) {
			small[i] = a[i];
		}
		else {
			small[i] = small[i + 1] + a[i];
		}
	}
	for (int i = 2 * N - 1; i >= N; --i) {
		if (a[i] < r.top()) {
			small[i] = small[i + 1] - r.top() + a[i];
			r.pop();
			r.push(a[i]);
		}
		else {
			small[i] = small[i + 1];
		}
	}

	long long ans = numeric_limits<long long>::min();
	for (int i = N - 1; i < 2 * N; ++i) {
		ans = max(ans, large[i] - small[i + 1]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 9588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int now = 1;
    int cnt = 0;
    rep(i,n) {
        if(v[i]!=now) cnt++;
        else {
            now++;
        }
    }
    if(now==1) cout << -1 << endl;
    else cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

#define PB push_back

void Input(int*,vector<string>&);
void Bubblesort(int*,vector<string>);
void Selectionsort(int*,vector<string>);
void Output(int*,vector<string>);

vector<string> vstr_bubble;

int main(int argc,char* argv[]){

  int n;
  vector<string> vstr;

  Input(&n,vstr);
  Bubblesort(&n,vstr);
  Selectionsort(&n,vstr);

  return 0;
}

void Input(int* pn,vector<string>& vstr){
  string str;
  
  cin>>*pn;
  for(int i=0;i<*pn;i++){
    cin>>str;
    vstr.PB(str);
  }
}

void Bubblesort(int *pn,vector<string> vstr){
  
  for(int i=0;i<*pn;i++){
    for(int j=*pn-1;j>i;j--){
      if(vstr[j-1][1]>vstr[j][1]){
	swap(vstr[j-1],vstr[j]);
      }
    }
  }

  Output(pn,vstr);
  puts("Stable");

  vector<string>::iterator itvstr;
  for(itvstr=vstr.begin();itvstr!=vstr.end();itvstr++)
    vstr_bubble.PB(*itvstr);
}

void Selectionsort(int*pn,vector<string> vstr){

  for(int i=0;i<*pn;i++){
    int key=i;
    for(int j=i+1;j<*pn;j++){
      if(vstr[key][1]>vstr[j][1])
	key=j;
    }
    swap(vstr[i],vstr[key]);      
  }

  Output(pn,vstr);

  bool flag=true;
  for(int i=0;i<*pn;i++){
    if(vstr_bubble[i]!=vstr[i]){
      flag=false;
      break;
    }
  }
  if(flag)
    puts("Stable");
  else
    puts("Not stable");
}

  void Output(int *pn,vector<string> vstr){

    cout<<vstr[0];
    for(int i=1;i<*pn;i++)
      cout<<" "<<vstr[i];
    puts("");
  }

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
bool w[100010];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++) w[gi()]^=1,w[gi()]^=1;
    for(int i=1;i<=n;i++) if(w[i]) return puts("NO"),0;
    puts("YES");
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}
 
Node treeSearch(Node u, int k){
  if(u == NIL || u->key == k) return u;
  else if(u->key > k) return treeSearch(u->left, k);
  else if(u->key < k) return treeSearch(u->right, k);
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;
  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
 
}
 
void inorder(Node u){
  if(u->left != NIL) inorder(u->left);
  printf(" %d", u->key);
  if(u->right != NIL) inorder(u->right);
}
void preorder(Node u){
  printf(" %d", u->key);
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
}
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 19364
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int D[101];
int main() {
	cin>>N;
	int A[101]={};
	int ans=N;
	for(int i=0;i<N;i++){
		cin>>D[i];
		A[D[i]]++;
	}

	for(int i=1;i<101;i++){
		if(A[i]>1)ans=ans-A[i]+1;
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    int N;
    cin >> N;
    int a = N;
    int S = 0;
    while(a != 0) {
            int b = a % 10;
            a = (a-b)/ 10;
            S += b;
    }
    if(N % S == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
 
int main()
{
  int a[3][3] ;
  set<int> st[8] ;
  for(int i = 0 ; i < 3 ; i++)
  {
    for(int j = 0 ; j < 3 ; j++)
    {
      cin >> a[i][j] ;
    }
  }
  for(int i = 0 ; i < 3 ; i++)
  {
    st[i].insert(a[i][0]) ;
    st[i].insert(a[i][1]) ;
    st[i].insert(a[i][2]) ;
    st[i+3].insert(a[0][i]) ;
    st[i+3].insert(a[1][i]) ;
    st[i+3].insert(a[2][i]) ;
  }
  st[6].insert(a[0][0]) ;  st[6].insert(a[1][1]) ; st[6].insert(a[2][2]) ;
  st[7].insert(a[0][2]) ; st[7].insert(a[1][1]) ; st[7].insert(a[2][0]) ;
  int n ;
  cin >> n ;
  set<int> b ;
  for(int i = 0 ; i < n ; i++)
  {
    int tmp ;
    cin >> tmp ;
    b.insert(tmp) ;;
  }
  bool ok = false ;
  for(int i = 0 ; i < 8 ; i++)
  {
    set<int> stt = st[i] ;
    ok = true ;
    for(auto j : stt)
    {
      if(!b.count(j))
        	ok = false ;
    }
    if(ok)
      break ;
  }
  
  
  if(ok)
    cout << "Yes\n" ;
  else
    cout << "No\n" ;
  return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if (abs(a-c) <= d) cout << "Yes" << endl;
    else if ((abs(a-b) <= d) &&(abs(b-c) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

int PSA[(int)1e5 + 5];
int A[(int)1e5 + 5];

int main()
{
    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    for (int i = 1; i <= (int)s.length() - 1; i++)
    {
        A[i] = ((s[i - 1] == 'A' && s[i] == 'C') ? 1 : 0);
    }
    for (int i = 1; i <= s.length() + 4; i++)
    {
        PSA[i] += PSA[i - 1] + A[i];
    }
    for (; Q > 0; Q--)
    {
        int l, r; cin >> l >> r;
        int result = PSA[r] - PSA[l - 1];
        if (A[r] == 1) result--;
        cout << result << "\n";
    }
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int NMAX =1e5 + 10;

int main(int argc, char const *argv[])
{
	ll n,init = 100;
	int index=0;
	scanf("%lld",&n);
	while(init < n)
	{
		init = init*1.01;
		index++;
	}
	printf("%d\n",index );
	return 0;
}

Measured memory_bytes: 3828
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int than(int a, int b);
int main(void)
{
	int a, b = 0;
	scanf("%d%d", &a, &b);
	than(a, b);
	return 0;
}
int than(int a, int b)
{
	if (a > b){
		printf("a > b\n");
	}
	else if (a == b) {
		printf("a == b\n");
	}
	else {
		printf("a < b\n");
	}
	return 0;
}


Measured memory_bytes: 2040
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {

    int n, k;
    cin >> n >> k;
    vector<ll> tapu(n);
    REP(i, n) cin >> tapu[i];
    sort(all(tapu));

    ll ans = accumulate(tapu.begin(), tapu.begin() + k, 0ll);
    cout << ans << endl;


}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3152
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

for i in range(N):
  P[i] -= 1

ans = max(C)
S = set(range(N))
while S:
  scores = []
  x = S.pop()
  while True:
    scores.append(C[x])
    x = P[x]
    if x not in S:
      break
    S.remove(x)
  l = len(scores)
  if K <= l:
    for i in range(l):
      if scores[i] <= 0:
        continue
      ss = 0
      for k in range(K):
        ss += scores[(i+k)%l]
        ans = max(ans, ss)
  else:
    t = sum(scores)
    if t < 0:
      t = 0
    q, r = divmod(K, l)
    for i in range(l):
      if scores[i] <= 0:
        continue
      ss = t * (q - 1)
      for k in range(l):
        ss += scores[(i+k)%l]
        ans = max(ans, ss + (t if k < r else 0))

print(ans)

Measured memory_bytes: 69136
N,K,Q=map(int,input().split())
A = [int(input()) for _ in range(Q)]

score = [K-Q] * (N+1)
for i in A:
    score[i] += 1
ans = '\n'.join('Yes' if p > 0 else 'No' for p in score[1:])
print(ans)

Measured memory_bytes: 11324
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    string s;cin >> s;
    sort(s.begin(),s.end());
    bool a[26];
    for(int i=0;i<26;i++){
        a[i]=false;
    }
    for(int i=0;i<s.size();i++){
        a[s[i]-'a']=true;
    }
    
    for(int i=0;i<26;i++){
        if(a[i]==false){
            cout << char('a'+i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LS(): return list(sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

A, B = LI()
print(max(A+B,A-B,A*B))


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a <= b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first; printf("\n"); }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first; printf(" "); put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first; printf("\n"); putn(rest...); }

template<typename T>
vector<T> divisor(T n) {
	vector<T> res1;
	vector<T> res2;

	for (T i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res1.push_back(i);
			if (i != n / i) {
				res2.push_back(n / i);
			}

		}
	}
	RREP(i, res2.size()) {
		res1.push_back(res2[i]);
	}
	return res1;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	int sum = 0;
	REP(i,n){
		cin >> a[i];
		sum += a[i];
	}
	
	vector<int> div = divisor(sum);
	int res = 0;
	REP(j, div.size()) {
		vector<int> r(n);
		REP(i, n) {
			r[i] = a[i] % div[j];
		}
		sort(all(r));
		int sum1 = accumulate(all(r),0);
		int index = n - 1 - sum1 / div[j];
		if (0 <= index && index < n) {
			int sum2 = accumulate(r.begin(), r.begin() + index + 1, 0);
			if (sum2 <= k) {
				chmax(res, div[j]);
			}
		}
	}
	put(res);
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);
	//10^9<INT_MAX(2,147,483,647)<10^10
	public void run() {
		long a=sc.nextLong(),b= sc.nextLong();
		ln(String.format("%d %d %.8f", a/b,a%b,(double)a/b));
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}
	public static void ln() {
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include<stdio.h>


main(){
  int n,i;
  long min,max,total,count;
  max=-9999999999;
  min=9999999999;
  total=0;
  count=0;
  scanf("%d",&n);
  int st[n];
  for(i=0;i<n;i++){
    scanf("%d",&st[i]);
  }

  for(i=0; i<n;i++){
    if(st[i]>max){
      max=st[i];
    }
    if(st[i]<min){
      min=st[i];
    }
    total=total+st[i];
  }
  printf("%ld %ld %ld\n",min,max,total);
}



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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> a(n+1,INT_MAX);
	for (int i=0; i<n; i++)
		cin>>a[i];
	int cur=0, mx=0;
	for (int i=1; i<=n; i++)
		if(a[i]>a[i-1]) mx=max(mx,cur), cur=0;
		else cur++;
	cout<<mx<<"\n";
	return 0;
}

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Internal (accursedUnutterablePerformIO)
import qualified Data.Set as S
import System.IO.Unsafe
import Debug.Trace

unew :: VU.Unbox a => Int -> VUM.IOVector a
unew !n = accursedUnutterablePerformIO $ VUM.unsafeNew n

uread :: VU.Unbox a => Int -> VUM.IOVector a -> a
uread !i !v = accursedUnutterablePerformIO $ VUM.unsafeRead v i

uwrite :: VU.Unbox a => Int -> a -> VUM.IOVector a -> VUM.IOVector a
uwrite !i !a !v =
  accursedUnutterablePerformIO $ VUM.unsafeWrite v i a >> return v

umodify :: VU.Unbox a => Int -> (a -> a) -> VUM.IOVector a -> VUM.IOVector a
umodify !i !f !v =
  accursedUnutterablePerformIO $ VUM.unsafeModify v f i >> return v

uthaw :: VU.Unbox a => VU.Vector a -> VUM.IOVector a
uthaw !v = accursedUnutterablePerformIO $ VU.unsafeThaw v

ufreeze :: VU.Unbox a => VUM.IOVector a -> VU.Vector a
ufreeze !v = accursedUnutterablePerformIO $ VU.unsafeFreeze v

solve :: Int -> Int -> VU.Vector Int -> Int
solve n k hs = uread (n - 1) dp
 where
  -- dp[i]: minimal cost of moving from 1st to i-th place
  dp = VU.foldl'
    ( \(!dp) (!i, !v) -> if i == 0
      then uwrite 0 0 dp
      else uwrite
        i
        ( minimum
          [ uread j dp + abs (v - hs VU.! j)
          | j <- [i - k .. i - 1]
          , 0 <= j
          , j < n - 1
          ]
        )
        dp
    )
    (unew n)
    (VU.indexed hs)

main = do
  let readInt = fmap (second B.tail) . B.readInt

  (n, k) <-
    (\vec -> (vec VU.! 0, vec VU.! 1)) . VU.unfoldrN 2 readInt <$> B.getLine
  hs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n k hs


Measured memory_bytes: 3708
function Main(input) {
  input = input.split("\n");
  var a = input[0];
  var b = input[1];
  var c = input[2];
 
  var aList = [a.split(""), "A"];
  var bList = [b.split(""), "B"];
  var cList = [c.split(""), "C"];
 
  var turn = aList;
 
  while (true) {
    if (turn[0].length > 0) {
      var first = turn[0][0];
      turn[0].shift();
      if (first === "a") {
        turn = aList;
      }
      if (first === "b") {
        turn = bList;
      }
      if (first === "c") {
        turn = cList;
      }
    } else if (!(turn[0].length > 0)) {
      console.log(turn[1]);
      break;
    }
  }
}
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    vector<pair<int, bool>> trade; // true: buy, false: sell
    rep(i, n) cin >> a[i];
    ll ans = 1000;
    ll stock = 0;
    int old = 0;
    bool up = false;
    rep(i, n) {
        if (i == 0) {
            old = a[i]; continue;
        }
        if (old < a[i]) up = true;
        else if (a[i] < old && up) {
            trade.emplace_back(i - 1, false);
            up = false;
        }
        old = a[i];
    }
    if (up) trade.emplace_back(n - 1, false);
    bool down = false;
    for (int i = n - 1; i >= 0; --i) {
        if (i == n - 1) {
            old = a[i]; continue;
        }
        if (a[i] < old) down = true;
        else if (old < a[i] && down) {
            trade.emplace_back(i + 1, true);
            down = false;
        }
        old = a[i];
    }
    if (down) trade.emplace_back(0, true);
    sort(ALL(trade));
    rep(i, trade.size()) {
        if (trade[i].second == true) {
            stock += ans / a[trade[i].first];
            ans -= a[trade[i].first] * (ans / a[trade[i].first]);
        }
        else {
            ans += a[trade[i].first] * stock;
            stock = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
N, K = map(int, input().split())
h = list(map(int, input().split()))

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])


for i in range(2, N):
    for j in range(1, K + 1):
        if dp[i] > dp[i - j] + abs(h[i] - h[i - j]):
            dp[i] = dp[i - j] + abs(h[i] - h[i - j])

print(dp[-1])

Measured memory_bytes: 52448
#include<stdio.h>
int main()
{
	int n,m,c,i=0,count=0;
	int b[20]={0},a[20]={0};
	scanf("%d%d%d",&n,&m,&c);
	for(;i<m;i++)
	{
		scanf("%d",&b[i]);
	}
	while(n--)
	{
		int sum=0;
		for(i=0;i<m;i++)
		{
			scanf("%d",&a[i]);
		}
		for(i=0;i<m;i++)
		{
			sum+=b[i]*a[i];
		}
		if((sum+c)>0)
		{
			count++;
		} 
		 
	}
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define N_MAX 30000

char first_digit[10];

#define IX2(a, b) ((a) * 10 + b)
char first_two_digits[10][10];

#define IX3(a, b, c) ((a) * 100 + (b) * 10 + c)
char full_passcode[10][10][10];

char input[N_MAX];
int count;

int main (void) {
    int n, i, j, k;

    scanf("%d\n", &n);

    for (i = 0; i < n; i++) {
        input[i] = getchar() - '0';
    }

    for (i = 0; i < n - 2; i++) {
        if (first_digit[input[i]]) {
            continue;
        } else {
            first_digit[input[i]] = 1;
        }

        for (j = i + 1; j < n - 1; j++) {
            if (first_two_digits[input[i]][input[j]]) {
                continue;
            } else {
                first_two_digits[input[i]][input[j]] = 1;
            }

            for (k = j + 1; k < n; k++) {
                if (full_passcode[input[i]][input[j]][input[k]]) {
                    continue;
                } else {
                    full_passcode[input[i]][input[j]][input[k]] = 1;
                    count++;
                }
            }
        }
    }

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


Measured memory_bytes: 128
#include<string>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>

using namespace std;

int h,w,datac,cnt;
int fie[51][51];
int num[30];
int up[30],used[30];
int min_x[30],min_y[30],max_x[30],max_y[30];
bool flag;

void check(int v){
	if(flag)return;
	if(v==cnt){
		bool ok=true;
		for(int i=0;i<cnt;i++){
			if(max_x[i]>=min_x[i]){
				for(int j=min_x[i];j<=max_x[i];j++){
					for(int k=min_y[i];k<=max_y[i];k++){
						if(fie[j][k]==-1)ok=false;
						else if(up[i]>up[fie[j][k]])ok=false;
					}
				}
			}
		}
		if(ok)flag=true;
	}else{
		for(int i=0;i<cnt;i++){
			if(used[i]==0){
				used[i]=1;
				up[v]=i;
				check(v+1);
				up[v]=-1;
				used[i]=0;
			}
		}
	}
}
int main(void){
	scanf("%d",&datac);
	for(int ddd=0;ddd<datac;ddd++){
		scanf("%d %d",&h,&w);
		for(int i=0;i<30;i++){
			min_x[i]=min_y[i]=51;
			max_x[i]=max_y[i]=-1;
		}
		cnt=0;
		memset(fie,-1,sizeof(fie));
		memset(num,-1,sizeof(num));
		for(int i=0;i<h;i++){
			string str;
			cin >> str;
			for(int j=0;j<w;j++){
				if(str[j]>='A' && str[j]<='Z'){
					if(num[str[j]-'A']==-1)num[str[j]-'A']=cnt++;
					fie[j][i]=num[str[j]-'A'];
					min_x[fie[j][i]]=min(min_x[fie[j][i]],j);
					min_y[fie[j][i]]=min(min_y[fie[j][i]],i);
					max_x[fie[j][i]]=max(max_x[fie[j][i]],j);
					max_y[fie[j][i]]=max(max_y[fie[j][i]],i);
				}
			}
		}
		flag=false;
		check(0);
		printf("%s\n",flag?"SAFE":"SUSPICIOUS");
	}
	return 0;
}

Measured memory_bytes: 1232
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
#include <map>
#include <limits>
#include <algorithm>
#include <numeric>

using namespace std;

struct DDMY{ ostringstream o; template<class T>DDMY& operator,(const T &t){o<<t<<",";return *this;} string operator*(){ return o.str().substr(0,o.str().size()-1); } };
#define debug(args...) cout<<"("#args")=("<< *(DDMY(),args)<<") (L"<<__LINE__<<")"<<endl
template<class T> std::ostream &operator<<(std::ostream &o,const std::vector<T> &v)
{ o << "["; for(std::size_t i=0;i<v.size();i++) o << v[i] << (i < v.size()-1 ? ",":""); return o << "]"; }
template<class T,class U> std::ostream &operator<<(std::ostream &o,const std::pair<T,U> &v)
{ return o << v.first << ":" << v.second; }
template<class T,class U> std::ostream &operator<<(std::ostream &o,const std::map<T,U> &v)
{ o << "{"; typename std::map<T,U>::const_iterator i=v.begin(),j=i;++j;for(;i!=v.end();++i,++j) o << *i << (j!=v.end()? ",":""); return o << "}"; }
template<class T> std::ostream &operator<<(std::ostream &o,const std::set<T> &v)
{ o << "{"; typename std::set<T>::const_iterator i=v.begin(),j=i;++j;for(;i!=v.end();++i,++j) o << *i << (j!=v.end()? ",":""); return o << "}"; }



long _main(int n, vector<long> pile){
  long all = accumulate(pile.begin(), pile.end(), 0LL);
  long culm = 0;
  long min_value = numeric_limits<long>::max();
  for(int i = 0; i < pile.size() - 1; i++){
    culm += pile[i];
    long diff = abs(culm - (all - culm));
    if(min_value > diff){
      min_value = diff;
    }
  }
  return min_value;
}


int main(int argc, char *argv[])
{
  string line;
  getline(cin, line);
  int n = strtol(line.c_str(), NULL, 10);
  getline(cin, line);
  istringstream iss(line);
  vector<long> pile;
  for(int i = 0; i < n; i++){
    long k = 0;
    iss >> k;
    pile.push_back(k);
  }
  cout << _main(n, pile) << endl;
  return 0;
}


Measured memory_bytes: 7024
import java.util.Arrays;
import java.util.Scanner;
import java.util.InputMismatchException;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String inputN = scanner.nextLine();
		
		String inputP = scanner.nextLine();
		String[] pStr = inputP.split(" ", 0);
		
		int n = Integer.parseInt(inputN);
		int pInt[] = new int[n];
		for(int i=0;i<n;i++){
			pInt[i] = Integer.parseInt(pStr[i]);
		}
		
		Arrays.sort(pInt);
		
		System.out.println(pInt[n/2] - pInt[n/2-1]);
	}
}

Measured memory_bytes: 48948
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
  ll n, m, v, p;
  cin >> n >> m >> v >> p;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  sort(a.begin(), a.end());  // 入れ替えてもいいのでとりあえずソート

  vector<ll> rui(n + 1);  // 累積和とっとく
  for (int i = 0; i < n; i++) rui[i + 1] = a[i] + rui[i];

  // cout << a << endl;
  // cout << rui << endl;

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll tohyo = m * v;                                            // 残り投票数
    ll after = a[i] + m;                                         // m人全員がi番目に投票した姿
    ll ika = upper_bound(a.begin(), a.end(), a[i]) - a.begin();  // 自分以下の要素数
    tohyo -= ika * m;                                            // 自分以下には大量に投票してok
    ll migi = upper_bound(a.begin(), a.end(), after) - a.begin();
    if (p <= n - migi) continue;  // afterを超える存在が多すぎる
    if (n - ika <= p - 1) { // どうやってもいける
      ans++;
      continue;
    }
    tohyo -= (n - migi) * m;           // 元々負けが確定してる相手は積みまくってok
    ll bimcos = migi - ika;            // 微妙なやつの個数
    ll bimsum = rui[migi] - rui[ika];  // 微妙なやつの総和
    ll aki = bimcos * after - bimsum;  // 最大敷き詰めとの差
    tohyo -= aki;
    if (n - migi < p - 1) {  // もっと諦めれるなら差分をとって引く
      ll hami = (p - 1) - (n - migi);
      tohyo -= hami * m + (rui[migi] - rui[migi - hami]) - hami * after;
    }
    if (tohyo <= 0) {
      // cout << a[i] << "はいける" << endl;
      ans++;  // 残り投票数がない
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979323846;
const int MAX = 1e7;
const int MOD = 1e9+7;


int main(int argc, char *args[]) {
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 1; i <= n; i++) {
		v.push_back(i);
	}
	vector<int> p(n);
	vector<int> q(n);
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		p.push_back(a);
	}
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		q.push_back(a);
	}
	int counter = 0; 
	int s = -1, t = -1;
	do {
		counter++;
		if (p == v) s = counter;
		if (q == v) t = counter;
		if (s != -1 && t != -1)break;

	} while (next_permutation(v.begin(), v.end()));
	cout << abs(s - t) << endl;
}

Measured memory_bytes: 256
while True:
    m,f,r = [int(x) for x in input().split()]
    if m == f == r == -1:
        break
    else:
        if m == -1 or f == -1:
            print("F")
        elif m + f >= 80:
            print("A")
        elif 65 <= m + f <= 80:
            print("B")
        elif 50 <= m + f < 65:
            print("C")
        elif 30 <= m + f < 50 and r < 50:
            print("D")
        elif 30 <= m + f < 50 and r >= 50:
            print("C")
        elif m + f < 30:
            print("F")

Measured memory_bytes: 7660
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    int n;
    cin >> n;
    if(!n) break;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
    for(int i = 0; i < n; ++i) {
      int m, a, b;
      cin >> m >> a >> b;
      q.push(make_pair(a, m));
      q.push(make_pair(b, -m));
    }
    bool valid = true;
    int sum = 0;
    while(!q.empty()) {
      auto p = q.top(); q.pop();
      sum += p.second;
      while(!q.empty() && p.first == q.top().first) {
        sum += q.top().second; q.pop();
      }
      if (sum > 150) {
        valid = false;
        break;
      }
    }
    if (valid)
      cout << "OK" << endl;
    else
      cout << "NG" << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]){
	int n, m, res = 0;
	cin >> n >> m;
	int p[m];
	vector <int> swh[n];
	for(int i = 0; i < m; i++){
		int k, s;
		cin >> k;
		for(int z = 0; z < k; z++){
			cin >> s;
			swh[s - 1].push_back(i);
		}
	}
	for(int i = 0; i < m; i++){
		cin >> p[i];
	}
	int maxi = 1 << n;
	for(int i = 0; i < maxi; i++){
		int on[m] = {0};
		int counter = 0, val = i;
		while(val){
			if(val % 2){
				for(auto it: swh[counter])
					on[it] += 1;
			}
			val >>= 1;
			counter++;
		}
		int check = 0;
		for(int k = 0; k < m; k++){
			if(on[k] % 2 == p[k]) 
				check++;
		}
		if(check == m)
			res++;
	}
	cout << res;

	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

class Main {
    static StringBuilder sb = new StringBuilder("");

    public static void main (String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Node[] nodes = new Node[n];
        boolean[] isRoot = new boolean[n];

        Arrays.fill(isRoot, true);

        for (int i = 0; i < n; i++) {
            int id = sc.nextInt();
            int left = sc.nextInt();
            int right = sc.nextInt();
            if (left != -1) {
                isRoot[left] = false;
            }
            if (right != -1) {
                isRoot[right] = false;
            }

            nodes[id] = new Node(id, left, right);
        }

        int root = 0;
        for (int i = 0; i < n; i++) {
            if (isRoot[i]) {
                root = i;
            }
        }

        sb.append("Preorder\n");
        printPreorder(nodes, root);

        sb.append("\nInorder\n");
        printInorder(nodes, root);

        sb.append("\nPostorder\n");
        printPostorder(nodes, root);

        System.out.println(sb);
    }

    public static void printPreorder(Node[] nodes, int root) {
        if (root == -1) return;

        sb.append(" ").append(root);
        printPreorder(nodes, nodes[root].left);
        printPreorder(nodes, nodes[root].right);
    }

    public static void printInorder(Node[] nodes, int root) {
        if (root == -1) return;

        printInorder(nodes, nodes[root].left);
        sb.append(" ").append(root);
        printInorder(nodes, nodes[root].right);
    }

    public static void printPostorder(Node[] nodes, int root) {
        if (root == -1) return;

        printPostorder(nodes, nodes[root].left);
        printPostorder(nodes, nodes[root].right);
        sb.append(" ").append(root);
    }
}

class Node {
    public int id;
    public int parent;
    public int left;
    public int right;

    public Node(int id, int left, int right) {
        this.id = id;
        this.left = left;
        this.right = right;
    }
}

Measured memory_bytes: 26312
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    int f[n+1] = {};
    int c[n+1] = {};

    int AC = 0, WA = 0;

    rep(i,m){
        int p;
        string s;
        cin >> p >> s;
        if(s[0] == 'A'){
            if(f[p] == 0){
                WA += c[p];
                AC++;
                f[p] = 1;
            }
        }else{
            c[p]++;
        }
    }

    cout << AC << ' ' << WA << endl;
    return 0;
}
 
 


Measured memory_bytes: 1024
N,K = map(int,input().split())
P = list(map(float,input().split()))
Q = list(map(lambda x: (x+1)/2,P))

S = sum(Q[:K])
ans = S

for i in range(N-K):
    S = S-Q[i]+Q[K+i]
    ans = max(ans,S)

print(ans)

Measured memory_bytes: 77320
import math
def prime(n):
    if (n==2):
        return True
    if(n<2 or n%2==0):
        return False
    i=3
    while(i<=math.sqrt(n)):
        if (n%i==0):
            return False
        i=i+2
    return True

N=int(input())
count=0
for i in range(N):
    n=int(input())
    if(prime(n)):
        count+=1
print(count)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = 99999999;
const ll linf = 999999999999999999;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////



int main(){
    string a;
    cin >>a;
	
	ull ans = 0;
	bool flag[26] = {};
	set<ll> num[26];
	
    ll n = sz(a);

    if(n == 2){
        if(a[0] == a[1])P(1);
        else P(2);
        return 0;
    }
    
    rep(i,0,n){
        flag[a[i] - 'a'] = 1;

        num[a[i] - 'a'].it(i);
    }

    rep(i,0,26)if(flag[i] == 1)num[i].it(sz(a));
    
/*    rep(i,0,26){
        if(flag[i] == 1){
            cout << (char)('a' + i) << " ";
            for(auto it:num[i])cout << it << " " ;
            cout << endl;
        }
    }*/

    rep(i,0,26){
        if(flag[i] == 1){
            ll old = -1;
            ull cnt = 0;
            for(auto it:num[i]){
                if(old == -1){
                    old = it;
                }else{
                    ans += (it -(ull)old -1)*cnt;
                    old = it;
                }
                cnt ++;
            }

           // cout << (char)('a'+i) << " " <<ans << endl;
        }
    }
    
   
    if(ans == 1)P(1);
    else P(ans + 1);
	return  0;
}

Measured memory_bytes: 9860
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n + 1);
    v[0] = 0;
    rep(i, 0, n)
    {
        int temp;
        cin >> temp;
        v[i + 1] = v[i] + temp;
    }
    ll ans = INF;
    // rep(i, 0, n + 1) cout << v[i] << " ";
    // cout << endl;
    rep(i, 0, n) ans = min(ans, abs(ll(v[n] - v[i]) - v[i]));
    cout << ans << endl;
}

Measured memory_bytes: 3580
n = int(input())
a = [int(input()) for i in range(n)]

a = sorted(a)


s_a = a[0:n//2]
l_a = a[n//2:]

if len(s_a) == len(l_a):
    print(2*sum(l_a) - l_a[0] - 2*sum(s_a) + s_a[-1])

else:
    tmp_ans1 = 2*sum(l_a) - l_a[0] - l_a[1] - 2*sum(s_a)    
    s_a = a[0:n//2+1]
    l_a = a[n//2+1:]
    tmp_ans2 = 2*sum(l_a) - 2*sum(s_a) + s_a[-2] + s_a[-1]
    print(max(tmp_ans1, tmp_ans2))


Measured memory_bytes: 8272
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int n;cin>>n;
    vector<pair<double,double>>xy;
    REP(i,n){
        double x,y;cin>>x>>y;
        xy.pb(mp(x,y));
    }
    double m[n][n];
    REP(i,n)REP(j,n){
        if(i==j){m[i][j]==0;continue;}
        m[i][j]=sqrt((xy[i].fi-xy[j].fi)*(xy[i].fi-xy[j].fi)+(xy[i].se-xy[j].se)*(xy[i].se-xy[j].se));
        m[j][i]=m[i][j];
    }
    vector<int>p(n);
    REP(i,n)p[i]=i;
    double sum=0;
    int con=0;
    do{
        con++;
        REP(i,n-1){
            sum+=m[p[i]][p[i+1]];
        }
    }while(next_permutation(p.begin(), p.end()));
    cout<<setprecision(16)<<sum/con<<endl;
}
int main()
{
    cin.tie(0);
	ios::sync_with_stdio(false);
    solve();
    return 0;
}



Measured memory_bytes: 256
/******** JUST GIVE IT A TRY,COULD'NT SOLVED YOU LEARNED SOMETHING NEW 
AND IF SOLVED IT MEANS YOU GREW *********/
    
//author RKN
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define pr pair<ll,ll>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define N 200001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);  
/*///////////////////////////////////////////////////////////////
DYNAMIC PROGRAMMING
///////////////////////////////////////////////////////////////*/

int main()
{
        int n,k;
        cin>>n>>k;
        int arr[n];
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>dp(n+1);
        fill(all(dp),1e9);
        dp[0]=0;
        for(int i=1;i<n;i++)
        {
            for(int j=1;j<=k;j++)
            {
                if(i-j>=0)
                dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
            }
        }
        cout<<dp[n-1]<<"\n";
}

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

int main() {
	int x, y;
	cin >> x >> y;
	// 2a + 2b = 2x
	// 2a + 4b = y
	// b = (y-2x)/2 & a= x-b
	const auto z = y - 2 * x;
	const auto b = (z) / 2;
	if (z < 0 || z % 2 != 0 || b > x) {
		cout << "No";
	}else {
		cout << "Yes";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y,n;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	n=a+b+c+d;
	x=n/60;
	y=n%60;
	printf("%d\n",x);
	printf("%d\n",y);
	return 0;
}



Measured memory_bytes: 2108