akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main() 
{
    int N;
    cin>>N;
    vector<int>P,Q;
    for (int i = 0; i < N; i++)
    {
        int p;
        cin>>p;
        P.push_back(p);
    }
    for (int j = 0; j < N; j++)
    {
        int q;
        cin>>q;
        Q.push_back(q);
    }

    auto V = P;
    sort(V.begin(),V.end());
    
    vector<vector<int>> Vs;
    do
    {
        Vs.push_back(V);
    } while (next_permutation(V.begin(),V.end()));
    
    auto it1=find(Vs.begin(),Vs.end(),P);
    auto it2=find(Vs.begin(),Vs.end(),Q);

    auto ans1=distance(Vs.begin(),it1);
    auto ans2=distance(Vs.begin(),it2);
    
    cout<<abs(ans1-ans2)<<endl;

    return 0;
}


Measured memory_bytes: 6220
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        char[] chars = s.next().toCharArray();
        int[] n = new int[chars.length];

        for (int i = 0; i < chars.length; i++) {
            n[i] = Character.getNumericValue(chars[i]);
        }

        int wb = 0;
        int bw = 0;

        for (int i = 0; i < chars.length; i++) {
            if (i % 2 == 1 && n[i] == 0) {
                wb++;
            } else if (i % 2 == 0 && n[i] == 1) {
                wb++;
            } else if (i % 2 == 1 && n[i] == 1) {
                bw++;
            } else if (i % 2 == 0 && n[i] == 0) {
                bw++;
            }
        }
        System.out.println(wb < bw ? wb : bw);
    }
}

Measured memory_bytes: 26068
coins = [500,100,50,10,5,1]

loop do
  n = gets.to_i
  break if n == 0
  m = 1000 - n
  cnt = 0
  coins.each do |coin|
    while m - coin >= 0
      m -= coin
      cnt += 1
    end
  end
  puts cnt
end

Measured memory_bytes: 8568
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
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 (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)


int modPow(LL x, LL y){
    LL r = 1, a = x % MOD;
    while(y > 0){
        if((y&1) == 1) r = (r*a) % MOD;
        a = (a*a) % MOD;
        y /= 2;
    }
    return r;
}


int main() {
    LL N,a,b;cin >> N >> a >> b;
    LL ans = modPow(2,N);
    ans -= 1;

    LL A = 1;
    LL B = 1;
    rep(i,a)A = A*(N-i) % MOD; 
    rep(i,b)B = B*(N-i) % MOD;

    LL Ain = 1;
    LL Bin = 1;
    rep(i,a)Ain = Ain*(i+1) % MOD;
    rep(i,b)Bin = Bin*(i+1) % MOD;

    Ain = modPow(Ain,MOD-2);
    Bin = modPow(Bin,MOD-2);

    A = A * Ain % MOD;
    B = B * Bin % MOD;

    ans = ans - A - B;
    if(ans < 0){
        ans += MOD;
    }
    if(ans < 0){
        ans += MOD;
        ans % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rrep(i, b, a) for(int (i) = (b); (i) > (a); (i)--)
using namespace std;

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


ll arr[100'005];
map<ll, ll> mp;
ll ans = 0;

int main() {
	FASTIO;

	int n; cin >> n;
	rep(i, 0, n) {
		cin >> arr[i];
		mp[arr[i]]++;
		ans += arr[i];
	}
	int q; cin >> q;
	rep(i, 0, q) {
		ll b, c; cin >> b >> c;
		ans -= mp[b] * b;
		ans += mp[b] * c;
		mp[c] += mp[b];
		mp[b] = 0;
		cout << ans << endl;
	}

	return 0;
}




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

int i;

int main()
{
    int n;
    int long long sum = 0;
    cin >> n;

    for (i = 1; i <= n; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }

    cout << sum;
}

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

int main()
{
    //自作関数の宣言
    vector<unsigned long long> next_p_mod(unsigned, long long);
    unsigned long long modpow(unsigned long long , unsigned long long , unsigned long long);
    void comb(vector<vector<long long int>>, unsigned long long);
    unsigned long long modinv(unsigned long long , unsigned long long);
    //
    ll N;
  ll sum=0;
  cin>>N;
  vector<unsigned long long> d(N);
	for(int i=0;i<N;i++){
  cin>>d.at(i);
    }
  ll sum_buff=0;
  for(int i=0;i<N-1;i++){
  	for(int j=i+1;j<N;j++){
    sum_buff=d.at(i)*d.at(j);
    sum+=sum_buff;
    }
  }
	cout<<sum<<endl;
    return 0;
}

vector<unsigned long long> next_p_mod(unsigned N, long long mod)
{ //next_permutation
    vector<unsigned long long> Next_p(N);
    unsigned long long Next_p_buff = 1;
    for (int i = 0; i < N; i++)
    {
        Next_p_buff *= (i + 1) % mod;
        Next_p.at(i) = Next_p_buff % mod;
    }
    return Next_p;
}
unsigned long long modpow(unsigned long long a, unsigned long long n, unsigned long long mod)
{
    unsigned long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
void comb(vector<vector<long long int>> &v, unsigned long long mod)
{
    //vector<入れたい型> v(配列の個数(x),vector<入れたい型> (配列の個数,初期値));
    for (int i = 0; i < v.size(); i++)
    {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int k = 1; k < v.size(); k++)
    {
        for (int j = 1; j < k; j++)
        {
            v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]) % mod;
        }
    }
}
// a^{-1} mod を計算する
unsigned long long modinv(unsigned long long a, unsigned long long mod)
{
    return modpow(a, mod - 2, mod);
}

// modinv
/*void modinv(unsigned long long N, unsigned long long mod,unsigned long long *inv) {
 // unsigned long long inv[N] ;
  for (unsigned long long i = 1; i < N; i++) {
    inv[i] = (i == 1) ? 1 : (mod - (mod / i) * inv[mod % i] % mod);
    assert(inv[i] * i % mod == 1);
  }
  //return 0;
}*/




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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0);
   int n; cin >> n;
   int x = pow(n, 0.5);
   cout << x*x << nl;

   return 0;


}


Measured memory_bytes: 4076
void main()
{
    long n = rdElem;
    string[] s = rdRow!string;

    s.sort!"a < b";
    writeln(s.group.array.length == 3 ? "Three" : "Four");
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int pivot = 0;
	char str[15],monitor[15];
	scanf("%s" , &str);
	for(int i = 0 ; i < strlen(str) ; i++){
		if(str[i] == '0'){
			monitor[pivot] = '0';
			pivot++;
		}
		else if(str[i] == '1'){
			monitor[pivot] = '1';
			pivot++;
		}
		else if(str[i] == 'B'){
			if(pivot != 0){
				pivot--;
			}
		}
	}
	for(int i = 0 ; i < pivot ; i++){
		printf("%c" , monitor[i]);
	}
	
	
	
	return 0;
}

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

using namespace std;

using int64 = long long;

int N, A[100];

int dfs(int idx, int mult)
{
  if(idx == N) return (mult == 0);
  return (dfs(idx + 1, (mult * A[idx]) % 2) + dfs(idx + 1, (mult * (A[idx] + 1)) % 2) + dfs(idx + 1, (mult * (A[idx] - 1)) % 2));
}

int main()
{
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  cout << dfs(0, 1) << endl;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
S = [input() for k in range(H)]

for y in range(H):
    for x in range(W):
        if S[y][x] == "#":
            f = 1
            if y+1 < H:
                if S[y+1][x] == "#":
                    f = 0
            if x+1 < W:
                if S[y][x+1] == "#":
                    f = 0
            if 0 <= y-1:
                if S[y-1][x] == "#":
                    f = 0
            if 0 <= x-1:
                if S[y][x-1] == "#":
                    f = 0
            if f:
                print("No")
                exit(0)

print("Yes")


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

typedef long long int ll;
ll dp[100007], n, h[100007];

int main() {
    memset(dp, -1, sizeof(dp));
    cin >> n;
    for(ll i = 0; i < n; ++i) cin >> h[i];
    dp[0] = 0;
    
    for(ll i = 0; i < n; ++i) {
        if(i + 1 < n && (dp[i + 1] == -1 || dp[i + 1] > dp[i] + abs(h[i + 1] - h[i]))) dp[i + 1] = dp[i] + abs(h[i + 1] - h[i]);
        if(i + 2 < n && (dp[i + 2] == -1 || dp[i + 2] > dp[i] + abs(h[i + 2] - h[i]))) dp[i + 2] = dp[i] + abs(h[i + 2] - h[i]);
    }

    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 5192
K = int(input())
from collections import deque

queue = deque([1, 2, 3, 4, 5, 6, 7, 8, 9])

for _ in range(K):
    x = queue.popleft()
    nx = x * 10 + x % 10
    if x % 10 != 0:
        queue.append(nx - 1)
    queue.append(nx)
    if x % 10 != 9:
        queue.append(nx + 1)
print(x)

Measured memory_bytes: 40816
#include <bits/stdc++.h>
using namespace std;
int n, k, i, a[1005], s;
int main(){
    scanf("%d%d",&n, &k);
    for(i=1;i<=n;i++){
        scanf("%d", &a[i]);
    }
    sort(a+1, a+n+1);
    for(i=1;i<=k;i++){
        s+=a[i];
    }
    printf("%d", s);
    return 0;
}

Measured memory_bytes: 3800
#include <stdio.h>
int main(void)
{
    long int n;
    long int x[100005]={};
    long int y[100005]={};
    long int t[100005]={};
    long int dis;
    long int disx;
    long int disy;
    long int time;
    scanf("%ld",&n);
    x[0]=0;
    y[0]=0;
    t[0]=0;
    for(long int p=1;p<=n;p++)
    {
        scanf("%ld %ld %ld",&t[p],&x[p],&y[p]);
    }
    for(long int q=0;q<n;q++)
    {
        time=t[q+1]-t[q];
        disx=x[q+1]-x[q];
        disy=y[q+1]-y[q];
        dis=sqrt(disx*disx)+sqrt(disy*disy);
        //printf("##%ld,%ld##\n",dis,time);
        if(time<dis || (time-dis)%2==1)
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}


Measured memory_bytes: 2560
# include "bits/stdc++.h"
using namespace std;
using LL = long long;

int n;
string s;
map<string, LL> mp;
int main(){
    cin >> n;
    LL ans =  0;
    for(int i = 0;i < n;i++){
        cin >> s;
        sort(s.begin(), s.end());
        ans += mp[s]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11136
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

ll n,ans,i,k=0;cin>>n;
vector<ll> v;
for(i=1;i<10;i++) v.pb(i);
i=0;
while(k!=n)
{
	ans=v[i];
	if(ans%10!=0) v.pb(10*ans+ans%10-1);
	v.pb(10*ans+ans%10);
	if(ans%10!=9) v.pb(10*ans+ans%10+1);
	k++;i++;
}
cout<<ans;

return 0;
}

Measured memory_bytes: 6384
#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int d[n];
    int sum = 0;
    for(int i=0; i<n; i++){
        scanf("%d", &d[i]);
    }
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            sum += d[i]*d[j];
        }
    }
    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,ans=1;
    cin>>n;
    char s[n];
    scanf("%s",&s);
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstring>
using namespace std;
int h,w,mas[105][105],cnt;
bool used[105][105];
int dx[2][6]={{0 ,1 ,0 ,-1 ,-1 ,-1},{0 ,1 ,0 ,-1 ,1 ,1}};
int dy[6]={-1 ,0 ,1 ,0 ,-1 ,1};
void dfs(int,int);
int main(){
  cin >> w >> h;
  memset(used,true,sizeof(used));
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      cin >> mas[j][i];
    }
 }
  dfs(0,0);
  cout << cnt << endl;
}
void dfs(int x,int y){
  used[x][y] = false;
  for(int i=0;i<6;i++){
    int nx=dx[y%2][i]+x,ny=dy[i]+y;
    if(nx>=0&&nx<w+2&&ny>=0&&ny<h+2&&used[nx][ny]){
      if(mas[nx][ny]==0) dfs(nx,ny);
      else cnt++;
    }
  }
}

Measured memory_bytes: 1464
#include<stdio.h>
#define ST_SIZE ((1 << 18) - 1)
typedef long long int LL;
LL dat[ST_SIZE];
LL input(void);
void add(LL a, LL b, int x, LL k, LL l, LL r);
void get(LL k, LL n);
int main (void) {
  int command, x;
  LL i, n, q, s, t, n2 = 1;
  n = input();
  q = input();
  while (n2 < n) n2 *= 2;
  n = n2;
  for (i = 0; i < q; i++) {
    command = input();
    if (!command) {
      s = input();
      t = input();
      x = input();
      add(s - 1, t, x, 0, 0, n);
    } else {
      t = input();
      get(t - 1, n);
    }
  }
}
LL input(void)
{
  LL n = 0;
  int c = getchar_unlocked();
  if (c == '-') {
    c = getchar_unlocked();
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return -n;
  } else {
    do {
      n = 10 * n + c - '0';
      c = getchar_unlocked();
    } while (c >= '0' && c <= '9');
    return n;
  }
}
void add(LL a, LL b, int x, LL k, LL l, LL r)
{
  if (a >= r || b <= l) return;
  else if (a <= l && b >= r) dat[k] += x;
  else {
    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2 , (l + r) / 2, r);
  }
}
void get(LL k, LL n)
{
  LL res;
  k += n - 1;
  res = dat[k];
  while (k > 0) {
    k = (k - 1)/ 2;
    res += dat[k];
  }
  printf("%lld\n", res);
}


Measured memory_bytes: 3280
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace template
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = Convert.ToInt32(Console.ReadLine());
            int eve = 25-D;
                Console.Write("Christmas");
                for(;0<eve;eve--){
                    Console.Write(" Eve");
                    
            }

        }
    }
}

Measured memory_bytes: 11220
#include<cstdio>

int main(){
    int n, x, c = 0, arr[105];
    scanf("%d%d", &n, &x);
    arr[0] = 0;
    for(int i=0;i<n;i++){
        int l;
        scanf("%d", &l);
        arr[i+1] = arr[i] + l;
    }
    for(int i=0;i<=n;i++){
        if(arr[i]<=x){
            c++;
        }
        //printf("%d\n", arr[i]);
    }
    printf("%d", c);
    return 0;
}


Measured memory_bytes: 128
X = int(input())

if X >= 500:
    a, b = divmod(X, 500)
    if b >= 5:
        c, d = divmod(b, 5)
    else:
        c = 0
else:
    a = 0
    c, d = divmod(X, 5)

ans = (a*1000) + (c * 5)
print(ans)

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

typedef long long ll;

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

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

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

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

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

void solve() {
	string s;
	cin >> s;

	if(s == "ABC") cout << "ARC";
	else cout << "ABC";
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
double in,maxm,mini;
int main(){
	cin>>maxm;
	mini=maxm;
	while(cin>>in){
		maxm=max(maxm,in);
		mini=min(mini,in);
	}
	printf("%.6f\n",maxm-mini);
	return 0;
}

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

#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>

using namespace std;


//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int power(int a,int n)
{
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return a*power(a*a,n/2);
    return power(a*a,n/2);
}
const int md = 998244353;
const int inf = (int) 1e18;

/*int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}*/


signed main()
{
    showoff;
    int n,x[55],y[55];
    cin >> n;
    FOR(i,0,n)cin >> x[i] >> y[i];
    int ans = 0;
    FOR(i,0,n){
        FOR(j,0,n){
            int tot = 0,p = x[j]-x[i],q = y[j]-y[i];
            if(!p && !q)continue;
            FOR(k,0,n){
                FOR(l,0,n){
                    if(x[l]-x[k] == p && y[l]-y[k] == q)++tot;
                }
            }
            ans = max(ans,tot);
        }
    }
    cout << n-ans << "\n";
    return 0;     
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...    

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

int main(){
    string s;
    cin >> s;
    int cntr = 0;
    for(int i=0; i<s.size()/2; i++){
        if(s[i] != s[s.size()-i-1])
            cntr++;
    }
    cout << cntr;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

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

    vector<vector<int>> G(n);
    map<pi,int> e2id;
    rep(i,n-1){
        int a,b;
        cin >>a >>b;
        --a;
        --b;
        e2id[{a,b}] = i;
        e2id[{b,a}] = i;
        G[a].pb(b);
        G[b].pb(a);
    }

    vector<int> par;
    auto BFS = [&](int root){
        par = vector<int>(n,-1);
        vector<bool> vis(n);

        vis[root] = true;
        queue<int> que({root});
        while(!que.empty()){
            int v = que.front();
            que.pop();
            for(int e:G[v])if(!vis[e]){
                vis[e] = true;
                que.push(e);
                par[e] = v;
            }
        }
    };

    int m;
    cin >>m;

    vector<vector<bool>> c(m, vector<bool>(n-1));
    rep(i,m){
        int a,b;
        cin >>a >>b;
        --a;
        --b;

        BFS(a);
        int t = b;
        while(par[t]!=-1){
            int p = par[t];
            int idx = e2id[{t,p}];
            c[i][idx] = true;
            t = p;
        }
    }

    vector<ll> dp(1<<m);
    dp[0] = 1;
    rep(i,n-1){
        vector<ll> nx(1<<m);

        int bb = 0;
        rep(j,m)if(c[j][i]) bb |= (1<<j);

        // black
        rep(mask,1<<m) nx[mask|bb] += dp[mask];
        // white
        rep(mask,1<<m) nx[mask] += dp[mask];

        swap(dp,nx);
    }
    cout << dp[(1<<m)-1] << "\n";
    return 0;
}


Measured memory_bytes: 16764
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, k, s;
    cin >> n >> k >> s;
    vector<int> v;
    for(int i = 0; i < n; i++){
        if(i < k){
            v.PB(s);
        }
        else{
            if(s == 1){
                v.PB(s + 1);
            }else{
                v.PB(s - 1);
            }
        }
    }
    fprint(v);
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 1912
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,sum=0,i,j,k;
int main()
{
    cin>>a>>b>>c>>d;
    for(i=0;i<=a;i++)
        for(j=0;j<=b;j++)
            for(k=0;k<=c;k++)
                if(i*500+j*100+k*50==d)
                   sum++;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES 1
#define _EXT_CODECVT_SPECIALIZATIONS_H 1
#define _EXT_ENC_FILEBUF_H 1
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007ll
#define EPS 1e-9

#define getchar_unlocked _getchar_nolock
#define putchar_unlocked _putchar_nolock

typedef long long         ll;
typedef long double       ld;
typedef pair <ll,ll>      pl;
typedef tuple <ll,ll,ll>  tl;

ll X, Y, Z, K, A[1005], B[1005], C[1005];
vector <ll> sel, ans;
std::priority_queue < ll, vector<ll>, greater<ll> > pq;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> X >> Y >> Z >> K;
	for (ll i = 0; i < X; i++) cin >> A[i];
	for (ll j = 0; j < Y; j++) cin >> B[j];
	for (ll k = 0; k < Z; k++) cin >> C[k];
	
	for (ll i = 0; i < X; i++) {
		for (ll j = 0; j < Y; j++) {
			sel.push_back(A[i] + B[j]);
		}
	}
	
	sort(sel.begin(), sel.end(), greater<ll>());
	
	for (ll k = 0; k < Z; k++) {
		for (ll t = 0; t < min(K, (ll)sel.size()); t++) {
			ll tot = C[k] + sel[t];
			if ((ll)pq.size() < K) {
				pq.push(tot);
			} else if (tot > pq.top()) {
				pq.pop();
				pq.push(tot);
			} else break;
		}
	}
	
	while (!pq.empty()) {
		ans.push_back(pq.top());
		pq.pop();
	}
	
	for (ll t = K-1; t >= 0; t--) {
		cout << ans[t] << '\n';
	}
	
    return 0;
}

Measured memory_bytes: 10604
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let h: usize = sc.cin();
    let w: usize = sc.cin();
    let a: usize = sc.cin();
    let b: usize = sc.cin();
    for i in 0..h {
        for j in 0..w {
            print!("{}", if (j < a) ^ (i < b) { 1 } else { 0 });
        }
        println!("");
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9+7;

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

const int MAXN = 110;
int w[MAXN], v[MAXN];
int main() {
  int N, W;
  scanf("%d %d", &N, &W);
  int maxV = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &w[i], &v[i]);
    maxV += v[i];
  }

  vector<ll> dp(maxV + 1, LLINF);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    for (int sumV = maxV; sumV >= v[i]; sumV--) {
      dp[sumV] = min(dp[sumV], w[i] +  dp[sumV - v[i]]);
    }
  }

  for (int i = maxV; i >= 0; i--) {
    if (dp[i] <= W) {
      printf("%d\n", i);
      break;
    }
  }
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int ver[8][8] = { 0 };

int visit(int x, int n, int *visited) {
	int all_visited = 1;
	REP(i, n) if (visited[i] == 0) all_visited = 0;
	if (all_visited) return 1;
	int c = 0;
	REP(i, n) {
		if (visited[i] == 0 && ver[x][i] == 1) {
			visited[i] = 1;
			c += visit(i, n, visited);
			visited[i] = 0;
		}
	}
	return c;
}

int main() {
	int n, m, a, b, visited[8] = { 1 };
	scanf("%d%d", &n, &m);
	REP(i, m) {
		scanf("%d%d", &a, &b);
		ver[a - 1][b - 1] = 1;
		ver[b - 1][a - 1] = 1;
	}
	printf("%d\n", visit(0, n, visited));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main(void)
{

  int a, b, c; // aツつゥツづァツ暗ェツ氾板債つつ「ツ山
  int n;

  a = b = c = 0;
  
  for(int i = 0; i < 10; i++){
    cin >> n;
    if ( a < n ) {
      swap(a,n);
    }
    if ( b < n ) {
      swap(b,n);
    }
    if ( c < n ) {
      swap(c,n);
    }
  }

  cout << a << endl;
  cout << b << endl;
  cout << c << endl;
  
}

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

int main(void) {
unsigned long int A, B, C, D, E, F;
signed long int t;
t = 0;
cin >> A >> B >> C;
for (int i = 0; i < 100000; i++) {
if (A%2==0 && B%2==0 && C%2==0) {
D = (B+C)/2;
E = (C+A)/2;
F = (A+B)/2;
A = D;
B = E;
C = F;
t = t + 1;
} 
}
if (t == 100000) {
t = -1;
}
cout << t << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,l,r,sum=0,i,mid,a[100005],u,v;
ll cnt(ll x)
{
	int i;
	for(i=1;i<=n;i++)x-=x%a[i];
	return x;
}
int main()
{
	scanf("%lld",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]),sum+=a[i];
	if(a[n]!=2)
	{
		printf("-1\n");
		return 0;
	}
	//printf("%lld %lld %lld %lld\n",cnt(8),cnt(9),cnt(10),sum);
	l=1;r=sum+2;
	while(l<r)
	{
		mid=(l+r)/2;
		if(cnt(mid)>2)r=mid;
		else l=mid+1;		
	}
	u=l;
	l=1;r=sum+2;
	while(l<r)
	{
		mid=(l+r)/2;
		if(cnt(mid)>=2)r=mid;
		else l=mid+1;
	}
	if(u==l)
	{
		printf("-1\n");
		return 0;
	}
	printf("%lld %lld\n",l,u-1);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;
struct edge
{
    int to, cost;
};
using Graph = vector<vector<edge>>;

static const int MAX = 10000;

static const int YET = 0;
static const int CHK = 1;
static const int END = 2;

int n;
Graph G;

void dijkstra()
{
    priority_queue<pair<int, int>> pq;
    int seen[MAX];
    int dist[MAX];

    memset(seen, YET, sizeof(seen));
    //memset(dist, INF, sizeof(dist));
    rep(i, MAX) dist[i] = INF;

    dist[0] = 0;
    seen[0] = CHK;
    pq.push(make_pair(0, 0));

    while (!pq.empty())
    {
        auto minDistV = pq.top();
        pq.pop();
        int u = minDistV.second;
        int uc = minDistV.first * (-1);
        seen[u] = END;

        if (dist[u] < uc)
            continue;

        for (auto ne : G[u])
        {
            int nv = ne.to;
            int nvc = ne.cost;

            if (seen[nv] == END)
                continue;
            if (dist[u] + nvc < dist[nv])
            {
                dist[nv] = dist[u] + nvc;
                pq.push(make_pair(dist[nv] * (-1), nv));
                seen[nv] = CHK;
            }
        }
    }

    for (int i = 0; i < n; i++)
    {
        cout << i << " " << ((dist[i] == INF) ? -1 : dist[i]) << endl;
    }
}

void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

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

    cin >> n;
    G.resize(n);
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int vertex, cost;
            cin >> vertex >> cost;
            G[u].push_back((edge){vertex, cost});
        }
    }

    dijkstra();

    return;
}

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



Measured memory_bytes: 3412
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

vector<vector<int>> to;
vector<int> ans;

void bfs(int s) {
    queue<int> q;
    q.push(s);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto nv : to[v]) {
            if (ans[nv] != -1) continue;
            ans[nv] = v;
            q.push(nv);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    to.resize(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].pb(b);
        to[b].pb(a);
    }
    ans.resize(n, -1);
    bfs(0);
    cout << "Yes" << endl;
    for (int i = 1; i < n; ++i) cout << ans[i] + 1 << endl;
}

Measured memory_bytes: 10020
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Stack;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		
		int N = Integer.parseInt(br.readLine());
		
		st = new StringTokenizer(br.readLine());
		long[] psa = new long[N+1];
		psa[0] = 0;
		for(int i=1; i<=N; i++) {
			psa[i] = Integer.parseInt(st.nextToken()) + psa[i-1];
		}

		long[][] dp = new long[N][N];
		for(int i=N-1; i>=0; i--) {
			for(int j=i+1; j<N; j++) {
				dp[i][j] = Long.MAX_VALUE;
				for(int k=i; k<j; k++) {
					dp[i][j] = Math.min(dp[i][j], dp[i][k]+dp[k+1][j]);
				}
				dp[i][j] += psa[j+1]-psa[i];
			}
		}
		System.out.println(dp[0][N-1]);
	}
}


Measured memory_bytes: 34432
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
ll solve(ll a) {
  if (a==-1) return 0;
  if (a == 1 or a == 0) return a;
  ll pairNumber = (a - 1) / 2 + 1;
  if (a % 2 == 0)
    return a ^ (pairNumber % 2);
  else
    return (pairNumber % 2);
}
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll a, b;
  cin >> a >> b;
  ll res = solve(b) ^ solve(a - 1);
  cout << res << endl;
  ret;
}


Measured memory_bytes: 3624
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N, M = map(int, input().split())
    A, B = [], []
    for _ in range(N):
        A.append(input())
    for _ in range(M):
        B.append(input())

    for y in range(N - M + 1):
        for x in range(N - M + 1):
            ok = True
            for i in range(M):
                for j in range(M):
                    ok &= A[y + i][x + j] == B[i][j]

            if ok:
                print(Yes)
                return
    print(No)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3944
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
int main() {
    int y, m, d; char c1, c2; //y == 2019 only!!!
    cin >> y >> c1 >> m >> c2 >> d;
    if (m <= 4) cout << "Heisei" << endl;
    else cout << "TBD" << endl;
}


Measured memory_bytes: 256
N=int(input())
a=[int(i)//400 for i in input().split()]
s=set()
r=0
for i in range(N):
    if a[i]>=8:
        r+=1
    else:
        s.add(a[i])
print("{0} {1}".format(max([1,len(s)]),len(s)+r))


Measured memory_bytes: 2940
#include <bits/stdc++.h> 
#include <iostream>
#include<set>
#include<utility>
using namespace std;
#include<algorithm>
#define ll  long long 
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 ll int dp[101][100001];

ll int knap(ll int  arr[],ll int val[],ll int n, ll int w){
  if(n==0||w==0){
    return 0;
  }
  if(dp[n][w]!=-1){
      return dp[n][w];
  }
  else if(arr[n-1]>w){
    return  dp[n][w]= knap(arr,val,n-1,w);
  }
  else{
    return dp[n][w]=max(knap(arr,val,n-1,w),knap(arr,val,n-1,w-arr[n-1])+val[n-1]);
  }
}
int main() {
 ll int n,w;
 cin>>n>>w;
 ll int arr[n];
 ll int val[n];
 for(ll int i=0;i<n;i++){
   cin>>arr[i]>>val[i];
 }
 for(ll int i=0;i<101;i++){
   for(ll int j=0;j<100001;j++){
     dp[i][j]=-1;
   }
 }
 cout<<knap(arr,val,n,w)<<endl;
}

Measured memory_bytes: 79232
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	int card, now;
	vector<int> taro, hanako;

	while(cin >> card)
	{
		if(card == 0)
			break;

		taro.clear();
		hanako.clear();

		for(int i = 0; i < card; i++)
		{
			cin >> now;
			taro.push_back(now);
		}

		sort(taro.begin(), taro.end());
		now = 0;

		for(int i = 1; i <= card * 2; i++)
		{
			if(taro[now] == i)
			{
				now++;
			}
			else
			{
				hanako.push_back(i);
			}
		}

		vector<int>::iterator it;
		now = -1;

		while(1)
		{
			//taro phase
			if(now == -1)
			{
				now = taro.front();
				taro.erase(taro.begin());
			}
			else
			{
				for(it = taro.begin();; it++)
				{
					if(it == taro.end())
					{
						now = -1;
						break;
					}
					if(now < (*it))
					{
						now = (*it);
						taro.erase(it);
						break;
					}
				}
			}
			if(taro.empty() || hanako.empty())
			{
				break;
			}

			//hanako phase
			if(now == -1)
			{
				now = hanako.front();
				hanako.erase(hanako.begin());
			}
			else
			{
				for(it = hanako.begin();; it++)
				{
					if(it == hanako.end())
					{
						now = -1;
						break;
					}

					if(now < (*it))
					{
						now = (*it);
						hanako.erase(it);
						break;
					}
				}
			}

			if(taro.empty() || hanako.empty())
			{
				break;
			}
		}

		cout << hanako.size() << endl;
		cout << taro.size() << endl;
	}
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
using namespace std;
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define PI acos(-1)
#define MAX 200005

ll a[MAX];
int main()
{
    
    ll n,x;
    cin>>n;
    n=n-1;
    for(ll i=0;i<n;i++)
    {
        cin>>x;
        a[x]++;
    }

   for(ll j=1;j<=n+1;j++)
    cout<<a[j]<<endl;
    return 0;
}


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

int main()
{
	int A, B, count = 0;
	string S;

	cin >> A >> B >> S;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '-') {
			count++;
		}
	}

	if (S[A] == '-' && S.size() == (A + B + 1) && count == 1) {
		cout << "Yes" << endl;
	}

	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(a,b) vector<vector<int>>(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
using namespace std;


int main(){
    ll n;
    cin>>n;
    vector<pair<ll,int>>fs;
    for(ll i=2;i*i<=n;++i){
        int x=0;
        while(n%i==0){
            n/=i;
            ++x;
           
        }
   if(x!=0) fs.emplace_back(i,x);
    }
    if(n!=1)fs.emplace_back(n,1);
int ans=0;
for(auto p:fs){
    int x=p.se;
    int b=1;
    int i=1;
    while(x-i>=0){
        x=x-i;
        ++i;
        ans++;
    }}
cout<<ans<<endl;

}

Measured memory_bytes: 3632
# ABC 065 B

N = int(input())
A = [int(input()) for _ in range(N)]

i = 1
s = 0
while i != 2:
    s += 1
    A[i-1], i = 1, A[i-1]
    if i == 1:
        print(-1)
        break
else:
    print(s)

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int compare(vector<int> A, vector<int> B){
    if(A.size() >= B.size()){
        rep(i,B.size()){
            if(A[i] == B[i]){
                continue;
            }else if(A[i] > B[i]){
                return 0;
            }else{
                return 1;
            }
        }
        return 0;
    }else{
        rep(i,A.size()){
            if(A[i] == B[i]){
                continue;
            }else if(A[i] > B[i]){
                return 0;
            }else{
                return 1;
            }
        }
        return 1;
    }
}

int main()
{
    int n,m; cin >> n;
    vector<int> A(n);
    rep(i,n){
        int Ai; cin >> Ai;
        A[i] = Ai;
    }
    cin >> m;
    vector<int> B(m);
    rep(i,m){
        int Bi; cin >> Bi;
        B[i] = Bi;
    }
    cout << compare(A, B) << endl;
}


Measured memory_bytes: 3180
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = vec![];
    for _ in 0..n {
        a.push(read::<i64>());
    }
    let mut min_value = 1;
    let mut ans = 0;
    for num in a {
        if num == min_value {
            min_value = num + 1;
        } else {
            if num > min_value {
                ans += (num - min_value - 1) / min_value + 1;
            }
        }
        if min_value == 1 {
            min_value += 1;
        }
    }
    println!("{}", ans);
}

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(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352