akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

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

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
vector<int> a[N];
int64 dp[N][2];

void DFS(int u, int parent) {
  dp[u][0] = dp[u][1] = 1;
  for (auto& v : a[u]) {
    if (v == parent) continue;
    DFS(v, u);
    dp[u][0] = dp[u][0] * (dp[v][0] + dp[v][1]) % MOD;
    dp[u][1] = dp[u][1] * dp[v][0] % MOD;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  DFS(0, -1);
  int ret = (dp[0][0] + dp[0][1]) % MOD;
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
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; }

int n, m;

int main() {
    cin >> n;
    set<string> U;
    for(int i = 0; i < n; ++i) {
        string s; cin >> s;
        U.insert(s);
    }
    cin >> m;
    int cnt = 0;
    for(int i = 0; i < m; ++i) {
        string t; cin >> t;
        if(U.find(t) != U.end()) {
            if(cnt == 0) {
                cout << "Opened by " << t << endl;
            }else {
                cout << "Closed by " << t << endl;
            }
            cnt = (cnt+1)%2;
        }else {
            cout << "Unknown " << t << endl;
        }
    }

}


Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=9;i;i--)
	{
		if(n%i == 0&&n/i<10)
		{
			cout<<"Yes"<<endl;return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int i = 1;
      for(i=1;i<=5;i++){
        if(sc.nextInt()==0){
          break;
        }
      }
      System.out.println(i);
    }
}


Measured memory_bytes: 35556
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
template<class T>bool chmax(T&m,T x){if(m<x){m=x;return true;}return false;}

int dp[2][3];

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    std::vector<long long> b(N);
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
    }

    for (int i = 1; i <= N; i++)
    {
        dp[i%2][0] = max(dp[(i-1)%2][1]+a[i-1], dp[(i-1)%2][2]+a[i-1]);
        dp[i%2][1] = max(dp[(i-1)%2][2]+b[i-1], dp[(i-1)%2][0]+b[i-1]);
        dp[i%2][2] = max(dp[(i-1)%2][0]+c[i-1], dp[(i-1)%2][1]+c[i-1]);
    }

    int mx = -1;
    REP(j, 3) chmax(mx, dp[N%2][j]);

    cout << mx << endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int n;
  cin >> n;
  
  vector<int> v(n);
  for(int i; i < n; i++)
    cin >> v.at(i);
  
  int j = 1;
  int s = 0;
  
  while(j < n - 1){
    if(((v.at(j - 1) < v.at(j)) && (v.at(j) < v.at(j + 1))) || ((v.at(j + 1) < v.at(j)) && (v.at(j) < v.at(j - 1)))){
      s++;
    }
    j++;
  }
  cout << s << endl;
}
    

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int sum = 0;
    if (n > 1) sum += n * (n - 1) / 2;
    if (m > 1) sum += m * (m - 1) / 2;
    System.out.println(sum);
  }
}

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

int main() {
   int cinfir;
   cin >> cinfir;
   int i, arr[cinfir], maxv = -2000000000, minv;

   for(int n = 0; n < cinfir; n++) cin >> arr[n];
   
   minv  = arr[0];
   
   for(int j = 1; j < cinfir; j++) {
      maxv = max(maxv, arr[j] - minv);
      minv = min(minv, arr[j]);
   }

   cout << maxv << endl;
   return 0;
}


Measured memory_bytes: 3860
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int, int> P;

const int INF = 100000000;
const int MAX_H = 1000;
const int MAX_W = 1000;
const int MAX_N = 9;

//&#36755;入
int H, W, N;
char maze[MAX_H][MAX_W + 1];

int sx, sy;
int d[MAX_H][MAX_W];

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

//求以(sx, sy)&#20026;起点到&#36798;目&#26631;c的最短路径&#38271;度
int bfs(char c){
	//初始化
	for(int i = 0; i < H; i ++){
		fill(d[i], d[i] + W, INF);
	}
	d[sx][sy] = 0;
	queue<P> que;
	que.push(P(sx, sy));
	//&#23485;度&#20248;先
	while(!que.empty()){
		P p = que.front();
		que.pop();
		//已找到
		if(maze[p.first][p.second] == c){
			//重置起点
			sx = p.first;
			sy = p.second;
			break;
		}

		for(int i = 0; i < 4; i ++){
			int nx = p.first + dx[i], ny = p.second + dy[i];
			//判断是否可移&#21160;以及是否已&#32463;&#35775;&#38382;&#36807;
			if(0 <= nx && nx < H && 0 <= ny && ny < W && maze[nx][ny] != 'X' && d[nx][ny] == INF){
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
//	printf("%d, %d\n", sx, sy);
	return d[sx][sy];
}

void solve(){
	//找起始点
	for(int i = 0; i < H; i ++){
		for(int j = 0; j < W; j ++){
			if(maze[i][j] == 'S'){
				sx = i;
				sy = j;
				break;
			}
		}
	}
	//&#23485;度&#20248;先搜索
	int ans = 0;
	for(int i = 1; i <= N; i ++){
		ans += bfs('0' + i);
	}
	printf("%d\n", ans);
}

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

	scanf("%d %d %d", &H, &W, &N);
	for(int i = 0; i < H; i ++){
		scanf("%s", maze[i]);
	}
	solve();

	return 0;
}

Measured memory_bytes: 6096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main() {
    string A , B;
    cin >> A >> B;
    int a = A.size();
    int b = B.size();
    if(a > b){
        cout << "GREATER" << endl;
    }
    else if(b > a){
        cout << "LESS" << endl;
    }
    else if(A == B){
        cout << "EQUAL" << endl;
    }
    else if(A > B){
        cout << "GREATER" << endl;
    }
    else{
        cout << "LESS" << endl;
    }
}

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

#define endl "\n"
#define int long long

const int MOD = 1e9 + 7;
const int INF = 2e15;

void debug(vector <int> &dp, int l, int r) {
	for (int i = 1; i <= r; i++) {
		if (dp[i] == INF) cout << "inf ";
		else cout << dp[i] << " ";
	}
	cout << endl;
}

void max_self(int &a, int b) {
	a = max(a, b);
}

void min_self(int &a, int b) {
	a = min(a, b);
}

signed main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	int happiness[n + 1][3];
	for (int i = 1; i <= n; i++) {
		cin >> happiness[i][0] >> happiness[i][1] >> happiness[i][2];
	}

	vector <vector <int> > dp(n + 1, vector <int> (3, 0));

	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 3; j++) {
			int now = -INF;
			for (int k = 0; k < 3; k++) {
				if (k == j) continue;
				max_self(now, dp[i - 1][k]);
			}
			dp[i][j] = now + happiness[i][j];
		}
	}

	cout << *max_element(dp[n].begin(), dp[n].end()) << endl;

}

Measured memory_bytes: 11120
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            double X = double.Parse(Console.ReadLine());
            double deposit = 100;
            int cnt = 0;
            while(deposit < X)
            {
                deposit = Math.Floor(deposit * 1.01);
                cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}

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

static const int N = 100;

struct Matrix{int row, col;};
Matrix M[N];
int cost[N][N] = {0};

int prod(int begin, int end){
  int mincost = 100000000, l = end - begin;
  if(cost[begin][end] > 0){
    return cost[begin][end];
  } else {
    if(l == 0){
      mincost = 0;
    } else if(l == 1){
      cost[begin][end] = M[begin].row * M[begin].col * M[end].col;
      mincost = cost[begin][end];
    } else {
      int temp;
      for(int i = 0; i < l; i++){
        temp = prod(begin, begin + i) + prod(begin + i + 1, end);
        temp += M[begin].row * M[begin + i].col * M[end].col;
        mincost = min(mincost, temp);
      }
      cost[begin][end] = mincost;
    }
    return mincost;
  }
}

int main(){
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> M[i].row >> M[i].col;
  }

  cout << prod(0, n - 1) << endl;

  return 0;
}

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

typedef long long LL;

void setIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

int main() {
    setIO();
    int t; cin>>t;
    cout<<1-t<<endl;
    
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int main(){

  int s;
  scanf("%d",&s);
  int m;

  int memory[100000] = {0};
  memory[s] = 1;
  int flag = 0;
  int index = 1;

  while(flag == 0){
    index ++;
    if(s % 2 == 0){
      s /= 2;
    }else if(s % 2 == 1) s = 3*s +1;

    if(memory[s] == 0)memory[s] = 1;
    else{
      flag = 1;
      m = index;
    }
  }

  printf("%d",m);

  return 0;
}


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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int n; cin >> n;
   vector<string> s(n);
   for (int i = 0; i < n; ++i) {
      cin >> s[i];
   }

   int a = 0, b = 0, ba = 0, cnt = 0;
   for (auto S : s) {
      if (S[0] == 'B' && S[S.size()-1] == 'A') {
         ++ba;
      }
      else if (S[0] == 'B' && S[S.size()-1] != 'A') {
         ++b;
      }
      else if (S[0] != 'B' && S[S.size()-1] == 'A') {
         ++a;
      }

      bool prv_A = false;
      for (int i = 0; i < S.size(); ++i) {
         if (prv_A && S[i] == 'B') {
            ++cnt;
         }
         if (S[i] == 'A') {
            prv_A = true;
         } else {
            prv_A = false;
         }
      }
   }

   int ans = cnt + max(ba - 1, 0);
   if (ba > 0 && a > 0) {
      --a; ++ans;
   }
   if (ba > 0 && b > 0) {
      --b; ++ans;
   }
   ans += min(a,b);
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main()
{
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '1') {
			ans++;
		}
	}
	cout << ans << endl;
}

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

int main(){
  int cnt5, cnt7;
  cnt5 = cnt7 = 0;
  for (int i = 0; i < 3; i++) {
    int haiku; cin >> haiku;
    if (haiku == 5) cnt5++;
    if (haiku == 7) cnt7++;
  }
  if (cnt5 == 2 && cnt7 == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int a,b,c,k;
  int z=0;
scanf("%d %d %d %d",&a,&b,&c,&k);
	while(a>0){
    a--;
    k--;
    z++;
    if(k==0){
    printf("%d", z);
    return 0;
    }
    }
   while(b>0){
    b--;
    k--;
    if(k==0){
    printf("%d", z);
    return 0;
    }
   }
    while(c>0){
    c--;
    k--;
    z--;
    if(k==0){
    printf("%d", z);
    return 0;
    }
    }
}

Measured memory_bytes: 1736
#include <iostream>

using namespace std;

typedef long long lint;

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

const long long INF = 1LL << 60;

const int MAX_N = 110;
const int MAX_V = 100100;

int N;
lint W, weight[MAX_N], value[MAX_N];

lint dp[MAX_N][MAX_V];

int main() {
  cin >> N >> W;
  for (int i = 0; i < N; i++) {
    cin >> weight[i] >> value[i];
  }

  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_V; j++) {
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
      if (sum_v - value[i] >= 0) {
        chmin(dp[i + 1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
      }

      chmin(dp[i + 1][sum_v], dp[i][sum_v]);
    }
  }

  lint res = 0;
  for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
    if (dp[N][sum_v] <= W) res = sum_v;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 86400
#include<bits/stdc++.h>
using namespace std;
string s;
int cnt;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
		cnt=(cnt+s[i]-'0')%9;
	if(cnt==0)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 3712
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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;
}

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

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	map<ll, ll> ma;
	ll cnt = 0;
	rep(i, n) {
		cin >> a[i];
		ma[a[i]]++;
		if (ma[a[i]] > a[i])cnt++;
	}
	for (auto itr : ma) {
		if (itr.second < itr.first)cnt += itr.second;
	}
	cout << cnt;
	
	return 0;
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  int ans;
  for(int i = n; i <= 999; i++){
    if(i/100 == (i/10)%10 && i/100 == i %10){
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,st,e;
    string s;
    cin>>s;
    
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='A')
        {
            st=i+1;
            break;
        }
    }
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='Z')
        {
            e=i+1;
        }
    }
    x=e-st+1;
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline

H, W, D = map(int, input().split())
grid = []
for i in range(H):
    grid.append(list(map(int, input().split())))

place = []


for i in range(H):
    for j in range(W):
        place.append([grid[i][j], i, j])
place.sort()


classify = [[0] for i in range(D)]

for i in range(D):
    for j in range(i, H*W-D, D):
        classify[(i+1)%D].append(abs(place[j+D][1]-place[j][1])+abs(place[j+D][2]-place[j][2]) + classify[(i+1)%D][-1])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    ans = str(classify[R%D][(R-1)//D] - classify[L%D][(L-1)//D])
    print(ans)


Measured memory_bytes: 26460
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    bool ok = true;
    ll n,m; cin >> n >> m;
    string str(n, 'a');
    rep(i,m){
        ll s,c; cin >> s >> c;
        s--;
        if(str[s] != 'a' && str[s] != '0' + c){ok = false;break;}
        str[s] = '0' + c;
    }
    if(str[0] == '0' && n != 1)ok = false;
    if(str[0] == 'a'){
        if(n != 1)str[0] = '1';
        else str[0] = '0';
    }
    reps(i,n-1)if(str[i] == 'a')str[i] = '0';

    cout << (ok ? str : "-1") << endl;;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

while true do
  a.sort!
  
  while true do
    if a[0] > 0 then
      break
    end
    a.shift
  end
  
  
  if a.size == 1 then
    break
  end
  
  m = a[0]
  
  (1...a.size).each do |i|
    a[i] = a[i] % m
  end
end
  
puts a[0].to_s

Measured memory_bytes: 10240
#include<cstdio>

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	int sum=0;
	rep(i,n){
		char c;
		int a; scanf(" %c%d",&c,&a);
		if(c=='(') sum+=a;
		else       sum-=a;
		if(sum<0) return puts("NO"),0;
	}
	puts(sum==0?"YES":"NO");

	return 0;
}

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n; cin >> n;
  int current_money = 1000;
  int current_stock = 0;
  int values[n];
  REP(i,n) {
    cin >> values[i];
  }
  // string s;
  REP(i,n-1) {
    int qua = current_money / values[i];
    if(values[i] < values[i+1]) {
      current_stock += qua;
      current_money -= qua * values[i];
    } else if(values[i] > values[i+1]) {
      current_money += current_stock * values[i];
      current_stock = 0;
    }
  }
  cout << current_money + current_stock * values[n-1];
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int m=110000;
int a,b,c[m],d[m];
int main()
{
    scanf("%d%d",&a,&b);
    for (int i = 1; i <= a; i++) 
        scanf("%d",&c[i]); 
    memset(d,0x3f,sizeof(d)),d[1]=0;
    for (int i = 2; i <= a; i++) 
        for (int j = 1; j<i && j<=b; j++)
            d[i]=min(d[i],d[i-j]+abs(c[i]-c[i-j]));
    printf("%d",d[a]);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    int n; cin >> n;
    vector<int> A(9, 0);
    REP(i, n){
        int a; cin >> a;
        if(1<=a && a<=399) A[0]++;
        if(400<=a && a<=799) A[1]++;
        if(800<=a && a<=1199) A[2]++;
        if(1200<=a && a<=1599) A[3]++;
        if(1600<=a && a<=1999) A[4]++;
        if(2000<=a && a<=2399) A[5]++;
        if(2400<=a && a<=2799) A[6]++;
        if(2800<=a && a<=3199) A[7]++;
        if(3200<=a) A[8]++;
    }
    int cnt = 0;
    REP(i, 8){
        if(A[i]!=0) cnt++;
    }
    if(A[8]!=0){
        if(cnt == 0) cout << 1 << " " << cnt+A[8] << endl;
        else cout << cnt <<  " " << cnt+A[8] << endl;
    }
    else{
        cout << cnt << " " << cnt << endl;
    }
}

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

Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
S=[0 for i in range(N+1)]
for i in range(N):
    S[i+1]=S[i]+A[i]
B=A[::-1]
T=[0 for i in range(N+1)]
for i in range(N):
    T[i+1]=T[i]+B[i]
F=[0 for i in range(N)]
G=[0 for i in range(N)]
for i in range(N):
    LS=S[i+1]
    k=0
    if i!=0:
        k=F[i-1]
    if k!=0:
        k-=1
    tmp=LS
    for j in range(k,i+1):
        L=S[j]
        R=LS-S[j]
        if abs(R-L)<=tmp:
            F[i]=j
        else:
            break
        tmp=abs(R-L)
    if F[i]<=0:
        F[i]=0
for i in range(N):
    RS=T[i+1]
    k=0
    if i!=0:
        k=G[i-1]
    if k!=0:
        k-=1
    tmp=LS
    for j in range(k,i+1):
        L=T[j]
        R=RS-T[j]
        if abs(R-L)<=tmp:
            G[i]=j
        else:
            break
        tmp=abs(R-L)
    if G[i]<=0:
        G[i]=0
ans=S[N]
for i in range(N):
    A=[0 for i in range(4)]
    k=0
    if i!=0:
        k=F[i-1]
    A[0]=S[k]
    A[1]=S[i]-S[k]
    A[2]=T[N-i]-T[G[N-i-1]]
    A[3]=T[G[N-i-1]]
    score=max(A)-min(A)
    if ans>score:
        ans=score
print(ans)


Measured memory_bytes: 46620
#include<bits/stdc++.h>
using namespace std;
long gcd(long x,long y){
  return (x%y==0?y:gcd(y,x%y));
}

int main(){
  long N;cin>>N;
  vector<long>A(N);
  for(long i=0;i<N;i++)cin>>A[i];
  vector<bool>isprime(1001,1);
  vector<long>primes;
  for(long i=2;i<=1000;i++)if(isprime[i]){
    primes.push_back(i);
    for(long j=0;i*j<=1000;j++)isprime[i*j]=0;
  }
  vector<bool>used(1000001,0);
  bool pc=1;
  for(long i=0;i<N;i++){
    long a=A[i];
    for(long p:primes){
      if(a%p==0){
        if(used[p])pc=0;
        used[p]=1;
        while(a%p==0)a/=p;
      }
    }
    if(a!=1){
      if(used[a])pc=0;
      used[a]=1;
    }
  }
  long g=A[0];
  for(long i=1;i<N;i++)g=gcd(g,A[i]);
  cout<<(pc?"pairwise coprime":(g==1?"setwise coprime":"not coprime"));
}

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

using pii = pair<int, int>;

int main() {
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for(int i = 0; i < h; ++i) {
        cin >> s[i];
    }

    vector<vector<int>> v(h - 1, vector<int>(w - 1));
    for(int i = 0; i < h - 1; ++i) {
        for(int j = 0; j < w - 1; ++j) {
            int p = 0;
            for(int di = 0; di <= 1; ++di) {
                for(int dj = 0; dj <= 1; ++dj) {
                    p += s[i + di][j + dj] == '#';
                }
                v[i][j] = p % 2 == 0;
            }
        }
    }
    vector<vector<int>> hist(h - 1, vector<int>(w - 1));
    for(int i = 0; i < h - 1; ++i) {
        for(int j = 0; j < w - 1; ++j) {
            if(v[i][j] == 0) continue;
            if(i != 0) hist[i][j] = hist[i - 1][j];
            hist[i][j] += 1;
        }
    }

    int ans = max(h, w);
    for(int i = 0; i < h - 1; ++i) {
        vector<vector<int>> len(2, vector<int>(w - 1));
        for(int lp = 0; lp < 2; ++lp) {
            stack<pii> st; st.emplace(-1, -1);
            for(int j = 0; j < w - 1; ++j) {
                while(st.top().first >= hist[i][j]) st.pop();
                len[lp][j] = j - st.top().second;
                st.emplace(hist[i][j], j);
            }
            reverse(begin(hist[i]), end(hist[i]));
        }
        reverse(begin(len[1]), end(len[1]));
        for(int j = 0; j < w - 1; ++j) {
            ans = max(ans, (hist[i][j] + 1) * (len[0][j] + len[1][j]));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 37504
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int leng=s.length();
  int count=0;
  for(int i=0;i<leng;i++)
  {
    if(s[i]=='o')
      count++;
  }
  if(15-leng+count>=8)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    static long[] a, p;
    public static void main(String[]$) {
        int n = scanner.nextInt();
        long m = scanner.nextLong();
        a = new long[n + 1];
        p = new long[n + 1];
        a[0] = 1;
        p[0] = 1;
        for (int i = 1; i < n; i++) {
            a[i] = a[i - 1] * 2 + 3;
            p[i] = p[i - 1] * 2 + 1;
        }

        System.out.println(f(n, m));
    }

    static long f(int n, long x) {
        if (n == 0)
            return x <= 0 ? 0 : 1;
        if (x <= a[n - 1] + 1)
            return f(n - 1, x - 1);
        return p[n - 1] + 1 + f(n - 1, x - 2 - a[n - 1]);
    }
}

Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
int main(){
//int a,b;
  int z;
  cin>>z;
  vector<int>v;
  for(int i=1;i<=9;i++)
    for(int j=1;j<=9;j++)
    {int x=i*j;v.push_back(x);}
 /// int z=a*b;
  if(find(v.begin(),v.end(),z)!=v.end())
    cout<<"Yes";
  else
    cout<<"No";
  return 0;
}
    


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

int main() {
//vector <int> a(3);
int n,m;
cin >> n>>m ;

vector <int> aclist(n);
vector <int> walist(n);


for (size_t i = 0; i < m; i++)
{int pnum;
    string s;
    cin >> pnum>>s;
    if(s=="AC")
    {
        aclist.at(pnum-1)=1;
    }
    else if(s=="WA")
    {   if(aclist.at(pnum-1)!=1)
        {walist.at(pnum-1)++;}
    }
    
}
int ac=0;
int wa=0;

for (size_t i = 0; i < n; i++)
{
    ac+=aclist.at(i);
    if (aclist.at(i)!=0)
    {
    wa+=walist.at(i);
    }
    
}



cout << ac<<" "<<wa << endl;



}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
ll mod=1e9+7;		
double pi=3.1415926535897;	
	   
int main() {
			fast
			// #ifndef ONLINE_JUDGE
			// freopen("input.txt","r",stdin);
			// freopen("output.txt","w",stdout);
			// #endif

			ll a,b,h,m;
			cin>>a>>b>>h>>m;
			m=m+h*60;

			double hr=0.5*m;
			ll mn=(6*m)%360;

			double diff=abs(hr-mn);
			diff=min(diff,360-diff);
			
			double y=cos(diff*(pi/180.0));
			
			double ans=(double)a*a+(double)b*b-(double)2*a*b*y;
			cout<<fixed<<setprecision(10)<<sqrt(ans);



			return 0;
		 }	


Measured memory_bytes: 4176
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>

using namespace std;
typedef long long int ll;



int w,h,wp,hp;
ll dp[3010][3010],zero=0,maxs=1000000007;
string s;

ll mm(ll nq){
    return max(nq,zero);
}

void wi107(ll &nq){
    nq=nq%maxs;
}

int main(){
    scanf("%d %d",&h,&w);
    for(int i=0;i<=h+1;i++){
        dp[0][i]=-1;
        dp[w+1][i]=-1;
    }
    for(int i=0;i<=w+1;i++){
        dp[i][0]=-1;
        dp[i][h+1]=-1;
    }
    for(int i=1;i<=h;i++){
        cin>>s;
        for(int j=1;j<=w;j++){
            dp[j][i]=(s[j-1]=='#') ? -1:0;
        }
    }

    for(int i=1;i<=min(w,h);i++){
        for(int j=i;j<=w;j++){
            if(i==1){
                if(dp[j][i]==-1)break;
                dp[j][i]=1;
            }
            else if(dp[j][i]>=0)dp[j][i]=mm(dp[j-1][i])+mm(dp[j][i-1]);
            wi107(dp[j][i]);
            //else if(dp[j-1][i]>=0 and dp[j][i-1]>=0)dp[j][i]=dp[j-1][i]+dp[j][i-1];
        }
        for(int j=i+1;j<=h;j++){
            if(i==1){
                if(dp[i][j]==-1)break;
                dp[i][j]=1;
            }
            else if(dp[i][j]>=0)dp[i][j]=mm(dp[i-1][j])+mm(dp[i][j-1]);
            wi107(dp[i][j]);
            //else if(dp[i-1][j]>=0 and dp[i][j-1]>=0)dp[i][j]=dp[i-1][j]+dp[i][j-1];
        }
        
        //dp[i][i]=i;
    }
    
    /*
    for(int i=0;i<=h+1;i++){
        for(int j=0;j<=w+1;j++){
            printf("%d ",dp[j][i]);
        }
        cout<<endl;
    }
    */
    printf("%lld\n",dp[w][h]);
    
    
}


Measured memory_bytes: 23808
# -*- coding: utf-8 -*-
n=int(input())
a=list(map(int,input().split()))
count1=0
sum1=a[0]
if a[0]==0:
    count1=1
    sum1=1
for ii in range(1,n):
    S=sum1
    sum1+=a[ii]
    if sum1*S>=0:
        if S>0:
            count1+=sum1+1
            sum1=-1
        elif S<0:
            count1+=1-sum1
            sum1=1

if a[0]>=0:
    count2=a[0]+1
    sum2=-1
else:
    count2=1-a[0]
    sum2=1
for ii in range(1,n):
    S=sum2
    sum2+=a[ii]
    if sum2*S>=0:
        if S>0:
            count2+=sum2+1
            sum2=-1
        elif S<0:
            count2+=1-sum2
            sum2=1

print(min(count1,count2))


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

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

    int p, q, r;
    cin >> p >> q >> r;

    int x = p + q;
    int y = q + r;
    int z = r + p;

    cout << min(x, min(y, z)) << endl;

    return 0;
}

Measured memory_bytes: 256
s=input()
d=s.split()
n=int(d[0])
q=int(d[1])
end_t=0
processes=[]
for i in range(n):
    processes.append([])
    s=input()
    d=s.split()
    processes[i].append(d[0])
    processes[i].append(int(d[1]))

cnt=0
i=0
while True:
    if processes[0][1]<=q:
       end_t+=processes[0][1]
       print(processes[0][0],end_t)
       processes.pop(0)
       cnt+=1
       if cnt==n:
           break
   
    else:
       processes[0][1]-=q
       end_t+=q
       processes.append(processes[0])
       processes.pop(0)
       i+=1



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

int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    long long ans = 0;
    int cnt = 0 ;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'W') {
            ans += cnt;
        } else {
            cnt++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 720
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<f64>();
    let (w, h, x, y) = (input[0], input[1], input[2], input[3]);
    let n = 
    if w / 2. == x && h / 2. == y {
        1
    } else {
        0
    };
    println!("{} {}", w * h / 2., n);
}

Measured memory_bytes: 4352
n=int(input())
#最後に97を足せばよい
for i in range(n):
    cty=list(input())
    #αは26と互いに素
    con=[1,3,5,7,9,11,13,15,17,19,21,23,25]
    for alf in con:
        for bet in range(26):
            tmp=0
            voca=[]
            new=[]
            while tmp<len(cty):
                #単語ごとに区切る
                if ord(cty[tmp])<97:
                    new.append(''.join(voca))
                    #print(new)
                    voca=[]
                else:
                    voca.append(chr(((alf*(int(ord(cty[tmp])-97))+bet)%26)+97))
                tmp+=1
            new.append(''.join(voca))
            if 'that'in new or 'this'in new:
                for k in range(len(new)):
                    if k==len(new)-1:
                        print(''.join(new[k]))
                    else:
                        print(''.join(new[k]), end=' ')



Measured memory_bytes: 5596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
struct node{
	string s;
	int fen;
	int xu;
}re[100010];
bool cmp(node x,node y)
{
	if(x.s==y.s)
	{
		return x.fen>y.fen;	
	}
			
	return x.s<y.s;
	
}
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>re[i].s;
		scanf("%d",&re[i].fen);
	}
	for(int i=1;i<=n;i++)
	{
		re[i].xu=i;
	}
	sort(re+1,re+1+n,cmp);
	
	for(int i=1;i<=n;i++)
	{
		cout<<re[i].xu<<endl;
	}
}

Measured memory_bytes: 1792
#include<iostream>
#include<queue>
#include<vector>
#include<map>
#include<cstring>
using namespace std;
bool used[5005];
int town[5005][2];//??????????????¢
vector<int> v1[5005];
vector<pair<int,int> > v2[5005];
queue<int> bfs;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q1;

int main(){
	int n,m;
	int i,j,k,l;
	int a,b,c;
	cin>>n>>m;
	for(i=0;i<n;i++){
		cin>>town[i][0]>>town[i][1];
	}
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		v1[a].push_back(b);
		v1[b].push_back(a);
	}
	for(i=0;i<n;i++){
		for(j=0;j<v1[i].size();j++){
			bfs.push(v1[i][j]);
		}
		used[i]=true;
		for(j=0;j<town[i][1];j++){
			c=bfs.size();
			for(k=0;k<c;k++){//
				a=bfs.front(),bfs.pop();
				if(used[a])continue;
				used[a]=true;
				v2[i].push_back(make_pair(a,town[i][0]));
				for(l=0;l<v1[a].size();l++){
					if(used[v1[a][l]])continue;
					bfs.push(v1[a][l]);
				}
			}
		}
		memset(used,false,sizeof(used));
		while(!bfs.empty()){bfs.pop();}
	}
	q1.push(make_pair(0,0));
	while(!q1.empty()){
		a=q1.top().first,b=q1.top().second,q1.pop();
		if(b==n-1)break;
		if(used[b])continue;
		used[b]=true;
		for(i=0;i<v2[b].size();i++){
			if(used[v2[b][i].first])continue;
			q1.push(make_pair(v2[b][i].second+a,v2[b][i].first));
		}
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 192864
#include <iostream>
#include <algorithm>
#define mod 1000000007
using namespace std;
int a[20], f[20][1 << 16 | 5], fac[1 << 16 | 5], inv[1 << 16 | 5], pow2[1 << 16];
int C(int x, int y){
    if (x < y)
        return 0;
    return 1LL * fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int poww(int x, int y){
    int ans = 1;
    for (int i = 1; i <= y; i <<= 1, x = 1LL * x * x % mod)
        if (y & i)
            ans = 1LL * ans * x % mod;
    return ans;
}
int main(){
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++ i)
        cin >> a[i];
    pow2[0] = 1;
    for (int i = 1; i <= n; ++ i)
        pow2[i] = pow2[i - 1] * 2 % mod;
    fac[0] = 1;
    for (int i = 1; i <= pow2[n]; ++ i)
        fac[i] = 1LL * fac[i - 1] * i % mod;
    inv[pow2[n]] = poww(fac[pow2[n]], mod - 2);
    for (int i = pow2[n] - 1; i; -- i)
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
	inv[0] = 1;
    sort(a + 1, a + 1 + m);
    f[m + 1][0] = 1;
    for (int i = m; i; -- i){
        for (int s = 0; s < 1 << n; ++ s)
            f[i][s] = f[i + 1][s];
        for (int s = 0; s < 1 << n; ++ s){
            int cnt = 0;
            for (int j = 1; j <= n; ++ j)
                if (s >> (j - 1) & 1)
                    cnt += pow2[j - 1];
            int rst = pow2[n] - a[i] - cnt;
            for (int j = 1; j <= n; ++ j)
                if (! (s >> (j - 1) & 1) && pow2[j - 1] - 1 <= rst)
                    (f[i][s | (1 << j - 1)] += 1LL * f[i + 1][s] * C(rst, pow2[j - 1] - 1) % mod * fac[pow2[j - 1]] % mod) %= mod;
        }
    }
    int ans = 0;
    for (int i = 0; i < 1 << n; ++ i){
        int cur = f[1][i], cnt = 0, tot = 0;
        for (int j = 1; j <= n; ++ j)
            if (i >> (j - 1) & 1)
                cnt += pow2[j - 1], ++ tot;
        cur = 1LL * cur * fac[pow2[n] - cnt - 1] % mod;
        if (tot & 1)
            ans = (ans - cur + mod) % mod;
        else
            ans = (ans + cur) % mod;
    }
    ans = 1LL * ans * pow2[n] % mod;
    cout << ans << endl;
}


Measured memory_bytes: 4864
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int n;
  cin >> n;
  int a[100100];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }

  int m = (n + 1) / 2;
  int b[50100], c[50100];
  for (int i = 0; i < m; i++)
  {
    b[i] = a[2 * i];
  }
  sort(b, b + m);

  sort(a, a + n);
  for (int i = 0; i < m; i++)
  {
    c[i] = a[2 * i];
  }

  int ans = 0;
  int ib = 0;
  int ic = 0;
  while (ib < m)
  {
    if (b[ib] < c[ic] || ic == m)
    {
      ans++;
      ib++;
    }
    if (b[ib] == c[ic])
    {
      ib++;
      ic++;
    }
    else
    {
      ic++;
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 1024
import sys
read = sys.stdin.readline
import time
import math
import itertools as it
def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
start_time = time.perf_counter()
# ------------------------------

N = inp()
A = inpl()
A.sort()
dp = [False] * 1001001
nt = -1

for i in A:
    if i != nt:
        dp[i] = True
    else:
        dp[i] = False
    nt = i

ans = 0
mx = A[N-1]
nt = -1
for i in A:
    if dp[i]:
        ans += 1
    if i == nt:
        continue
    nt = i
    j = i
    while j <= mx:
        dp[j] = False
        j += i

print(ans)

# -----------------------------
end_time = time.perf_counter()
print('time:', end_time-start_time, file=sys.stderr)

Measured memory_bytes: 32296
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


K, S = ints()
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if 0 <= z <= K:
            # print(x, y, z)
            ans += 1

print(ans)


Measured memory_bytes: 68636
import heapq

n,m = map(int,input().split())

a = list(map(int,input().split()))

heapq.heapify(a)

l = [[] for _ in range(m)]

for i in range(m):
    b,c = map(int,input().split())
    l[i] = [c,b]
l.sort(reverse=True)
for i in range(m):
    b,c = l[i][1],l[i][0]
    for j in range(b):
        x = heapq.heappop(a)
        if(x < c):
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,x)
            break
print(sum(a))

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

void solve(int ca){
    while(true){
        int N,M; cin>>N>>M;
        if(N==0&&M==0) break;
        vector<int> c(M),x(N);
        for (int i = 0; i < M; ++i) {
            cin>>c[i];
        }
        for (int i = 0; i < N; ++i) {
            cin>>x[i];
        }
        vector<vector<ll>> dp(N+1,vector<ll>(256,INF));
        dp[0][128]=0ll;
        for (int i = 0; i < N; ++i) {
            for (int j = 0; j < 256; ++j) {
                for (int k = 0; k < M; ++k) {
                    int val=j+c[k];
                    if(val<0) val=0;
                    if(val>255) val=255;
                    chmin(dp[i+1][val],dp[i][j]+(x[i]-val)*(x[i]-val));
                }
            }
        }
        ll ans=INF;
        for (int i = 0; i < 256; ++i) {
            chmin(ans,dp[N][i]);
        }
        cout<<ans<<endl;
    }
}

//#define MULTI
int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}



Measured memory_bytes: 43792
#include <bits/stdc++.h>
#define ll long long
#define ii pair<int,int>
#define fr first
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
int n;
vector < int > v[200000];
int h[200000];
int sz[200000];
int par[200000];
int dfs(int node , int p)
{
    h[node] = h[p]+1;
    sz[node] = 1;
    par[node] = p;
    for(int i=0;i<v[node].size();i++)
    {
        if(p!=v[node][i])
         {
             dfs(v[node][i] , node);
             sz[node]+=sz[v[node][i]];
         }
    }
}
int main()
{
 cin>>n;
 for(int i=0;i<n-1;i++)
 {
     int x,y;
     cin>>x>>y;
     v[x].push_back(y);
     v[y].push_back(x);
 }
 dfs(1,0);
 int ans1 = sz[n];
 int ans2 = n - sz[n];
 int dis = h[n]-h[1]-1;
 dis = dis/2;
 int u = n;
 while(dis > 0)
 {
     u = par[u];
     dis--;
 }
 ans2 = sz[u];
 ans1 = n-sz[u];
 if(ans1 > ans2)
 {
     cout<<"Fennec";
 }
 else
    cout<<"Snuke";
}


Measured memory_bytes: 15744