akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;

class Convex_Hull_Trick {
    public:
    int n = 0;
    vector<Pll> lines;
    
    Convex_Hull_Trick() {}

    bool check(Pll line1, Pll line2, Pll line3) {
        return (line3.second-line2.second)*(line1.first-line2.first) > (line2.second-line1.second)*(line2.first-line3.first);
    }

    // 直線の傾きの降順に直線が与えられる前提
    void add(ll grad, ll intercept) {
        while(n >= 2 && !check(lines[n-2], lines[n-1], {grad, intercept})) {
            lines.pop_back();
            --n;
        }
        lines.emplace_back(grad, intercept);
        ++n;
    }

    ll f(ll i, ll x) {
        return lines[i].first*x + lines[i].second;
    }

    ll get_min(ll x) {
        int ok = 0, ng = n;
        while(ng-ok > 1) {
            int mid = (ok+ng)/2;
            if(mid && f(mid-1, x) >= f(mid, x)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        return f(ok, x);
    }
};

int main() {
    int n;
    ll  c;
    cin >> n >> c;
    vector<ll> h(n);
    Convex_Hull_Trick cht = Convex_Hull_Trick();
    for(int i=0;i<n;++i){
        cin >> h[i];
    }

    vector<ll> dp(n, 0);
    cht.add(-2*h[0], h[0]*h[0]);
    for(int j=1;j<n;++j) {
        dp[j] = cht.get_min(h[j]) + h[j]*h[j] + c;
        cht.add(-2*h[j], h[j]*h[j]+dp[j]);
    }

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


Measured memory_bytes: 9456
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C;
    cin>>A>>B>>C;
    int ans=A-B;
    int ans1=C-ans;
    if(ans1<=0)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<ans1<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace C_ABC137
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var sl = new List<string>();
            var al = new List<string>();
            var alcnt = new List<int>();
            for(int i = 0;i<s[0];i++){
                string str = ReadLine();
                var carr = str.ToCharArray();
                Array.Sort(carr);
                string cs =  new string(carr);
                al.Add(cs);
    //          WriteLine(cs);
            }
            var algrp = al.GroupBy(a=>a).Select(col=>new{p=col.Key,e=col.Count()});
            var alst = algrp.ToList();
            long ans = 0;
            for(int i=0;i<alst.Count;i++){
             //   WriteLine(alst[i].e);
                if(alst[i].e-1!=0){
                    ans+=((long)(alst[i].e)*(long)(alst[i].e-1))/2;

                }
            }

    
            WriteLine(ans);




        }

        public static bool Permutation(string a, string b)
        {
            if (a.Length != b.Length)
            {
                return false;
            }

            int[] letters = new int[256];
            char[] s_array = a.ToCharArray();
            foreach (char c in s_array)
            {
                letters[(int)c]++;
            }

            for(int i=0;i<b.Length;i++){
                int c = (int)b[i];
                if(--letters[c]<0){
                    return false;
                }
            }
            return true;


        }

    }
}


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

#define N 2000000

int heap[N], H;

void swap(int *a, int *b) {
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

int right(int id) {
    return (2 * id) + 1;
}

int left(int id) {
    return 2 * id;
}

int parent(int id) {
    return id / 2;
}

int max() {
    return 1;
}

void maxHeapify(int id) {
    int largest = id;

    if (left(id) <= H && heap[left(id)] > heap[largest]) {
        largest = left(id);
    }
    if (right(id) <= H && heap[right(id)] > heap[largest]) {
        largest = right(id);
    }

    if (largest != id) {
        swap(&heap[largest], &heap[id]);
        maxHeapify(largest);
    }
}

void buildMaxHeap(){
    int i;
    for (i = H/2; i > 0; i--) {
        maxHeapify(i);
    }
}

int heapExtractMax() {
    int result;

    if (H < 1) {
        printf("error\n");
        exit(1);
    }
    result = heap[max()];
    heap[max()]= heap[H];
    H--;
    maxHeapify(max());
    return result;
}

void heapIncreaseKey(int id, int key) {
    if (key < heap[id]) {
        return;
    }

    heap[id] = key;
    while (id > 1 && heap[parent(id)] < heap[id]) {
        swap(&heap[id], &heap[parent(id)]);
        id = parent(id);
    }
}

void heapInsertMax(int key) {
    H++;
    heap[H] = -1;
    heapIncreaseKey(H, key);
}

int main() {
    int i, input;
    char op[10];

    while (1) {
        scanf("%s", op);

        if (strcmp(op, "insert") == 0) {
            scanf("%d", &input);
            heapInsertMax(input);
        }
        if (strcmp(op, "extract") == 0) {
            scanf("%d", &input);
            printf("%d\n", heapExtractMax());
        }
        if (strcmp(op, "end") == 0) {
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 5628
/*#include <iostream>
#include <bits/stdc++.h>
#define fast_cin ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ll long long int
using namespace std;

vector<ll> dp(100005,0);
int m=1e9+7;
bool cmp(pair<int,int>&a,pair<int,int>&b)
{
    if(a.second==b.second)
        return a.first<b.first;
    else
        return a.second<b.second;
}

bool cmp_(pair<int,pair<int,int> >&a,pair<int,pair<int,int> >&b)
{
   return a.second.first<b.second.first;
}

void factorial()
{
    dp[1]=1;
    for(int i=2;i<=100000;i++)
    {
        dp[i]=((dp[i-1]%m)*(i%m))%m;
    }
}

int main()
{
    fast_cin;
      string s,t;
      cin>>s>>t;
      int n=s.length();
      int m=t.length();
      unsigned int dp[n+1][m+1];
      string ans;
      for(int i=0;i<=n;i++)
      {
          for(int j=0;j<=m;j++)
          {
              if(i==0||j==0)
                dp[i][j]=0;
              else if(s[i-1]==t[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
              else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
              if(ans.length()<dp[i][j])
                ans+=s[i];
          }
      }
      cout<<dp[n][m]<<endl;
      //cout<<ans<<endl;
    return 0;
}*/
#include <iostream>
#include <bits/stdc++.h>
#define fast_cin ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ll unsigned long long int
using namespace std;

vector<ll> dp(100005,0);
int mod=1e9+7;
bool cmp(pair<int,int>&a,pair<int,int>&b)
{
    if(a.second==b.second)
        return a.first<b.first;
    else
        return a.second<b.second;
}

bool cmp_(pair<int,int>&a,pair<int,int>&b)
{
   return a.second>b.second;
}

void factorial()
{
    dp[1]=1;
    for(int i=2;i<=100000;i++)
    {
        dp[i]=((dp[i-1]%mod)*(i%mod))%mod;
    }
}
void binary(int n)
{
    // array to store binary number
    int binaryNum[32];

    // counter for binary array
    int i = 0;
    while (n > 0) {

        // storing remainder in binary array
        binaryNum[i] = n % 2;
        n = n / 2;
        i++;
    }

    // printing binary array in reverse order
    for (int j = i - 1; j >= 0; j--)
        cout << binaryNum[j];
}
vector<int> grp[200005];
int visited[200005];
vector<int> time_in;
int cnt=0;
void dfs(int x,int c)
{
    if(c==0)
    {
        cnt=0;
        c=1;
    }
    visited[x]=1;
    for(int j:grp[x])
    {
        if(!visited[j])
            dfs(j,c);
    }
    cnt++;
    time_in[x] = cnt;
}
int main()
{
    fast_cin;
    int t;
    t=1;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        visited[n+1]={0};
        time_in.assign(n+1,0);
        for(int i=0;i<m;i++)
        {
            int u,v;
            cin>>u>>v;
            grp[u].pb(v);
            grp[v].pb(u);
        }
        for(int i=1;i<=n;i++)
        {
            if(!visited[i])
            {
                dfs(i,0);
            }
        }
        sort(time_in.begin(),time_in.end(),greater<int>());
        cout<<time_in[0];
    }
    return 0;
}


Measured memory_bytes: 25848
import bisect

N, Q = map(int, input().split())
S = input()
question = []
for i in range(Q):
  question.append(list(map(int, input().split())))

# Sの中で、ACという部分文字列が含まれるときの（Aの）index
index = []
for i in range(N-1):
  if S[i]+S[i+1] == "AC":
    index.append(i)

# i番目の文字以降に存在するACという部分文字列の数
sum_index = [0]*N
sum_ac = 0
for i in range(N-1):
  if S[N-(i+2)]+S[N-(i+1)] == "AC":
    sum_ac += 1
  sum_index[N-(i+2)] = sum_ac

for i, q in enumerate(question):
  ans = sum_index[q[0]-1] - sum_index[q[1]-1]
  print(ans)
    



Measured memory_bytes: 32644
#include <iostream>
#include <string>
using namespace std;
int henkan(int i){
	if('0'<=i && i<='9') return i-'0';
	else return i-'a'+10;
}
int main(){
	while(true){
		string s;
		cin >> s;
		if(s=="0") break;
		int r,g,b;
		r=henkan(s[1])*16+henkan(s[2]);
		g=henkan(s[3])*16+henkan(s[4]);
		b=henkan(s[5])*16+henkan(s[6]);
		bool rr=true,gg=true,bb=true;
		if(r<128) rr=false;
		if(g<128) gg=false;
		if(b<128) bb=false;
		if(rr && gg && bb) cout << "white";
		if(rr && gg && !bb) cout << "yellow";
		if(rr && !gg && bb) cout << "fuchsia";
		if(rr && !gg && !bb) cout << "red";
		if(!rr && gg && bb) cout << "aqua";
		if(!rr && gg && !bb) cout << "lime";
		if(!rr && !gg && bb) cout << "blue";
		if(!rr && !gg && !bb) cout << "black";
		cout << endl;
	}
	return 0;
}

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

using namespace std;

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

const ll mod = 1000000007;

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

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

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

  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  for (auto &x: a) cin >> x;

  for (auto &x: a) x /= 2;
  ll l = a[0];
  for (int i = 1; i < n; i++) {
    l = lcm(l, a[i]);
    if (l > m) {
      cout << 0 << endl;
      return 0;
    }
  }

  for (int i = 0; i < n; i++) {
    if ((l / a[i]) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = ((m / l) + 1) / 2;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 1024
program sample
    implicit none
  
    integer(8) :: i,j,m,n,k,l,q,t(100000)
    
    integer(8),allocatable :: a(:),b(:),c(:)
  
    read(*,*) n
    allocate(a(n))
    read(*,*)a
    read(*,*)q
    allocate(b(q))
    allocate(c(q))
    do i=1,q
        read(*,*)b(i),c(i)
    end do
    do i=1,10000
        t(i)=0
    end do
    do i=1,n
        m=a(i)
        t(m)=t(m)+1
    end do
    m=sum(a)


    do i=1,q
        k=b(i)
        l=c(i)
        m=m+(l-k)*t(k)
        t(l)=t(l)+t(k)
        t(k)=0
        
        write(*,*)m
    end do
    
    
    stop
end program sample
  



Measured memory_bytes: 6344
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
int f[1<<15][15];
int C[1<<15][15];
int c[15][15];
int cost(int S1,int S2){
  int ans=0;
  for(int i=0;i<n;++i){
    if(S2>>i&1)ans+=C[S1][i];
  }
  return ans;
}
int main(){
  scanf("%d%d",&n,&m);
  memset(c,0xc2,sizeof(c));
  for(int i=1,a,b,w;i<=m;++i){
    scanf("%d%d%d",&a,&b,&w);
    a--;b--;
    c[a][b]=c[b][a]=w;
  }
  int lim=1<<n;
  for(int i=0;i<lim;++i){
    for(int j=0;j<n;++j){
      for(int k=0;k<n;++k){
	if((i>>j&1)&&(!(i>>k&1))&&c[j][k]!=0xc2c2c2c2){
	  C[i][k]+=c[j][k];
	}
      }
    }
  }
  memset(f,0x3f,sizeof(f));
  f[1][0]=0;
  int ans=0x3f3f3f3f;
  for(int i=1;i<lim;++i){
    for(int j=0;j<n;++j){
      if(f[i][j]==0x3f3f3f3f)continue;
      for(int k=0;k<n;++k){
	if((!(i>>k&1))&&c[j][k]!=0xc2c2c2c2){
	  f[i|(1<<k)][k]=min(f[i|(1<<k)][k],f[i][j]+cost(i^(1<<j),1<<k));
	}
      }
      int S=(lim-1)^i;
      for(int j2=S;j2;j2=(j2-1)&S){
	f[i|j2][j]=min(f[i|j2][j],f[i][j]+cost(i^(1<<j),j2));
      }
    }
  }
  printf("%d\n",f[lim-1][n-1]);
  return 0;
}


Measured memory_bytes: 4096
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
from collections import deque, defaultdict
n = int(input())
#隣接リスト
G = defaultdict(lambda:[])
li = [] #答え用辺を保存するリスト
for _ in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    li.append((a, b))
    G[a].append(b)
    G[b].append(a)
parent = [0]*n #p[i]:頂点iの親
color = [-1]*n #color[i]:頂点iとその子vの色

#深さ優先探索でトポロジカル順序を決める
order = []
def dfs():
    parent[0] = -1
    stack = []
    u = 0
    stack.append(u)
    while stack:
        x = stack.pop()
        order.append(x)
        for v in G[x]:
            if v == parent[x]:
                continue
            parent[v] = x
            stack.append(v)

dfs()

#トポロジカル順序を決めたのでその順番で色を決めて行く
for x in order:
    temp = color[x]
    c = 1
    for y in G[x]:
        if y == parent[x]:
            continue
        if c == temp:
            c += 1
        color[y] = c
        c += 1
        
answer = []
for a, b in li:
    if parent[a] == b:
        answer.append(color[a])
    else:
        answer.append(color[b])

print(max(answer))
              
for i in answer:
    print(i)

Measured memory_bytes: 80732
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int N = sc.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
    }

    long ans = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 1) {
        continue;
      }
      ans += Integer.numberOfTrailingZeros(A[i]);

    }

    System.out.println(ans);

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 21972
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
using namespace std;

int main()
{
	long long int N, M, i, D, X, j,K, k, l, m, n, cnt;
	cin >> N;
	long long int sum = 0;
	long long int flag = 0;
	m = 0;
	vector<int>ans(N);
	for (i = 2;m<N-2; i++) {
		if ((i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0 || i % 11== 0)) {
			ans[m] = i;
			m++;
			sum += i;
		}
	}
	for (j = ans[N - 3] + 1;; j++) {
		if ((j % 2 == 0 || j % 3 == 0 || j % 5 == 0 || j % 7 == 0 || j % 11 == 0)&&((sum + j) % 2 == 0 || (sum + j) % 3 == 0 || (sum + j) % 5 == 0 || (sum + j) % 7 == 0 || (sum + j) % 11 == 0)){
			ans[N - 2] = j;
		sum += j;
		break;}
	}
	ans[N - 1] = 27720 - (sum % 2310);
	for (k = 0; k < N; k++) {
		cout << ans[k] << " " ;
	}
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <iterator>
#include <queue>
#include <stack>
#include <deque>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <string>
#include <cmath>
#include <complex>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cstdlib>
#include <cctype>
#define REP(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(int)c.size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define rall(u) (u).rbegin(),(u).rend()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl
#define v_delete(a,b) (a).erase(remove((a).begin(), (a).end(), b), (a).end())
#define v_unique(a) (a).erase(unique((a).begin(), (a).end()), (a).end())
#define VV(T) vector<vector< T > >
#define init(a,b) memset((a), (b), sizeof((a)))
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;


template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}

template <class T> void input(T& a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
template <class T> void input(T* a, int n) { for (int i = 0; i < n; ++i) cin >> a[i]; }
typedef pair<int,int> pii;

inline bool IN(int x, int y, int w, int h)
{
    return 0 <= x && x < w && 0 <= y && y < h;
}


int main()
{
	int n;
	cin >> n;
		rep(nn,n){
			int l[3];
			rep(i,3){
				cin >> l[i];
			}
			sort(l,l+3);
			if(pow(l[2],2.0)==pow(l[1],2.0)+pow(l[0],2.0)){
				cout << "YES" << endl;
			}else{
				cout << "NO" << endl;
			}

		}

	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <queue>

using namespace std;

char S = 'S';
char W = 'W';
char N = 'N';
char E = 'E';

class dice{
  private:
    int up;
    int down;
    int east;
    int west;
    int north;
    int south;
  public:
    dice(int up, int south, int east, int west, int north, int down);
    void move(char to);
    int get_up();
    int get_east();
    int get_south();
    bool has(int num);
    bool is_up_south(int _up, int _south);
    bool is_equal(dice* d);
    dice* clone();
};

bool dice::has(int num) {
  return up == num || down == num || north == num || south == num || west == num || east == num;
}

dice::dice(int _up, int _south, int _east, int _west, int _north, int _down) {
  up = _up;
  south = _south;
  east = _east;
  west = _west;
  north = _north;
  down = _down;
}

dice* dice::clone() {
  return new dice(up, south, east, west, north, down);
}

void dice::move(char to) {
  if(to == S) {
    int tmp = down;

    down = south;
    south = up;
    up = north;
    north = tmp;
  } else if (to == N) {
    int tmp = down;

    down = north;
    north = up;
    up = south;
    south = tmp;
  } else if (to == W) {
    int tmp = down;

    down = west;
    west = up;
    up = east;
    east = tmp;
  } else if (to == E) {
    int tmp = down;

    down = east;
    east = up;
    up = west;
    west = tmp;
  }
}

bool dice::is_up_south(int _up, int _south){
  return up == _up && south == _south;
}

bool dice::is_equal(dice *d){
  return up == d->up && 
	south == d->south &&
	down == d->down &&
	west == d->west &&
	east == d->east &&
	north == d-> north;
}

int dice::get_south() {
  return south;
}

int dice::get_east() {
  return east;
}

int dice::get_up(){
  return up;
}

dice* turn_dice(dice* d1, int to_up, int to_south) {
  queue<dice*> steps;
  steps.push(d1);

  for (int i = 0; i < 17; i++){
    dice* d = steps.front(); steps.pop();

    if (d->is_up_south(to_up, to_south)) {
        return d;
    }

    dice* cloned_d;

    cloned_d = d->clone();
    cloned_d->move(S);
    steps.push(cloned_d);

    cloned_d = d->clone();
    cloned_d->move(N);
    steps.push(cloned_d);

    cloned_d = d->clone();
    cloned_d->move(W);
    steps.push(cloned_d);

    cloned_d = d->clone();
    cloned_d->move(E);
    steps.push(cloned_d);
  }

  return d1;
}

int main() {
  int n;
  int up, south, east, west, north, down;
  string move;

  dice* dices[100];

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> up;
    cin >> south;
    cin >> east;
    cin >> west;
    cin >> north;
    cin >> down;

    dice* d1 = new dice(up, south, east, west, north, down);
    if (i > 0) {
      dices[i] = turn_dice(d1, dices[0]->get_up(), dices[0]->get_south());
    } else {
      dices[0] = d1;
    }
  }

  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      if (dices[i]->is_equal(dices[j])) {
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}



Measured memory_bytes: 3276
#include <cstdio>
#include <numeric>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int>> graph;
vector<long long> dat;

long long rec(int nod, int par) {
	long long ret = dat[nod] * 2;
	int ccnt = 0;
	vector<long long> subs;
	for (auto next : graph[nod]) {
		if (next == par) continue;
		ccnt++;
		long long sub = rec(next, nod);
		if (sub < 0) return -1;
		subs.push_back(sub);
		ret -= sub;
	}
	if (par == -1) {
		if (ccnt == 1) {
			ret -= dat[nod];
		}
		return ret == 0;
	}
	if (ccnt == 0)
		return dat[nod];
	if (ret > dat[nod])
		return -1;
	sort(subs.begin(), subs.end());
	long long smallsum = 0;
	for (int i = 0; i +1 < subs.size(); i++)
		smallsum+=subs[i];
	if (smallsum < dat[nod] - ret)
		return -1;
	return ret;
}

int main() {
	int n;
	scanf("%d",&n);
	dat.resize(n);
	for (int i = 0; i < n; i++) {
		scanf("%lld",&dat[i]);
	}
	graph.resize(n);
	for (int i = 0; i < n-1; i++) {
		int a,b;
		scanf("%d%d",&a,&b);
		a--,b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	int ret = rec(0, -1);
	if (ret <= 0) {
		printf("NO\n");
	} else {
		printf("YES\n");
	}
	return 0;
}


Measured memory_bytes: 17152
// AOJ 2595: Cookie Counter
// 2017.11.30 bal4u@uu

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

#define M 1000000007
#define MAX 2002
long long a[MAX];
long long b[MAX];

long long egcd(long long a, long long b, long long *x, long long *y)
{
	long long d;

	if (b == 0) { *x = 1; *y = 0; return a; }
	d = egcd(b, a % b, y, x);
	*y -= a / b * (*x);
	return d;
}

long long invMod(long long a)
{
  long long x, y;
  if (egcd(a, M, &x, &y) == 1) return (x + M) % M;
  return 0;
}

int main()
{
	int n, x, i, ii;
	long long d, ans, t;

    while (scanf("%d%lld%d", &n, &d, &x) && n > 0) {
		a[0] = b[0] = 1;
		for (i = 0; i <= n; i++) {
			t = invMod(i + 1);
			a[i+1] = (a[i] * ((d+i) % M) % M * t) % M;
			b[i+1] = (b[i] * ((d-i) % M) % M * t) % M;
		}
		ans = 0;
		for (ii = n/x, i = 0; i <= ii; i++) {
			t = a[n-x*i] * b[i] % M;
			if (i & 1) ans = (ans - t) % M;
			else	   ans = (ans + t) % M;
			if (ans < 0) ans += M;
		}	
        printf("%lld\n", ans);
	}
    return 0;
}

Measured memory_bytes: 1740
#include <cstdio>
#include <cmath>

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

typedef long long   signed int LL;
typedef long long unsigned int LU;

template<typename T> void swap(T &x, T &y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, ans;
char s[101];
char t[101];

int main() {
	scanf("%d%s%s", &n, s, t);
	
	inc(i, n + 1) {
		bool flag = true;
		inc(j, n - i) {
			if(s[j + i] != t[j]) { flag = false; break; }
		}
		if(flag) {
			ans = n + i;
			break;
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.*;

class Main
{
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	static FastScanner sc=new FastScanner(br);
    static PrintWriter out=new PrintWriter(System.out);
	static Random rnd=new Random();
	static HashSet<Integer> hs=new HashSet<>();
	static int[] arr=new int[]{400,800,1200,1600,2000,2400,2800,3200};
	
	static int get(int curr)
	{
		for(int i=0;i<arr.length;i++)
		{
			if(curr<arr[i]) return i;
		}
		
		return -1;
	}
	
    public static void main(String args[]) throws Exception
    {
		int n=sc.nextInt(),val=0;
		
		for(int i=0;i<n;i++)
		{
			int curr=sc.nextInt();
			
			if(curr>=3200)
			{
				val++;
			}
			else
			{
				hs.add(get(curr));
			}
		}
		
		out.println(Math.max(1,hs.size())+" "+(hs.size()+val));out.close();
    }
}
class FastScanner
{
    BufferedReader in;
    StringTokenizer st;

    public FastScanner(BufferedReader in) {
        this.in = in;
    }
	
    public String nextToken() throws Exception {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken();
    }
	
	public String next() throws Exception {
		return nextToken().toString();
	}
	
    public int nextInt() throws Exception {
        return Integer.parseInt(nextToken());
    }

    public long nextLong() throws Exception {
        return Long.parseLong(nextToken());
    }

    public double nextDouble() throws Exception {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 20692
using System;

class A
{
    static void Main()
    {
        var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(a[0] % a[1] > 0 ? a[0] / a[1] * a[2] + a[2] : a[0] / a[1] * a[2]);
    }
}

Measured memory_bytes: 27536
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for(int i = 1;;i++){
            int num = Integer.parseInt(sc.nextLine());
            if(num == 0) break;
            else System.out.println("Case " + i + ": " + num );
        }
        sc.close();
    }
}

Measured memory_bytes: 60032
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
int sum(vector<int> s){return accumulate(s.begin(),s.end(),0);}
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i,n)cin >> s[i];
    sort(s.begin(),s.end());
    int sum = accumulate(s.begin(),s.end(),0);
    int cnt = 0,min = 0;
    rep(i,n){
        if(s[i] % 10 == 0)cnt++;
        else if(min == 0)min = s[i];
    }
    if(cnt == n)cout << 0;
    else if(sum % 10 == 0) cout << sum-min;
    else cout << sum;
}

Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    LL N; cin >> N;
    if(N==0){
        cout << 0 << endl;
    }
    auto pfac = prime_factorize(N);
    LL ans = 0;
    for(auto p : pfac){
        LL cnt = 0;
        LL t = p.second;
        while((cnt+1)*cnt/2 <= t){
            cnt++;
        }
        ans += cnt-1;
    }
    cout << ans << endl;


}

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

int main() {
  int n; cin >> n;
  vector<int>b(n-1);
  rep(i, n-1) cin >> b[i];
  
  int ans=0;
  vector<int>a(n);
  
  a[0] = b[0];
  a[n-1] = b[n-2];
  
  for(int i=1; i<n-1; ++i) {
    a[i] = min(b[i], b[i-1]);
  }
  
  rep(i,n) ans += a[i];
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 500050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
//int dx[4] = { 0,0,-1,1 }, dy[4] = { 1,-1,0,0 };

void solve() {
	int X; cin >> X;
	if (X >= 30)print("Yes");
	else print("No");
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_7_A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            while (true)
            {
                int[] line = ReadIntAr();
                if (line.All(x => x == -1)) return;

                string rlt = string.Empty;
                if (line[0] * line[1] < 0)
                {
                    rlt = "F";
                }
                else
                {

                    int sum = line[0] + line[1];

                    if (sum >= 80) rlt = "A";
                    else if (sum >= 65) rlt = "B";
                    else if (sum >= 50) rlt = "C";
                    else if (sum >= 30)
                    {
                        if (line[2] >= 50) rlt = "C";
                        else rlt = "D";
                    }
                    else rlt = "F";
                }

                Console.WriteLine(rlt);

            }
          
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 16240
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define all(a)                      a.begin(), a.end()
#define pb                          push_back
#define ll							long long
#define index(a)            		order_of_key(a)
#define value(a)					find_by_order(a)
#define count_1 					__builtin_popcount
#define mod(x, m)					((((x) % (m)) + (m)) % (m))
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll a,b,c;
	cin>>a>>b>>c;
	if(c<=b)cout<<b+c;
	else {
		ll t=min(b,c);
		ll ans=2*t;
		b-=t;
		c-=t;
		//cout<<ans<<" "<<a<<" "<<b<<" "<<c<<endl;
		if(b>0)ans+=b;
		else{
			t=min(a,c);
			c-=t;
			a-=t;
			ans+=t;
			if(c>0)ans++;
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
A, B = map(int, input().split())
lst = []
for i in range(1, 10):
    for j in range(0, 10):
        for k in range(0, 10):
            lst.append(i * 10000 + j * 1000 + k * 100 + j * 10 + i)

ans = [0 for i in lst if A <= i <= B]
print(len(ans))

Measured memory_bytes: 3060
/*  -*- coding: utf-8 -*-
 *
 * 2877.cc: Aquarium
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N];
ll asums[MAX_N + 1];
double dp[MAX_N + 1][MAX_N + 1];

/* subroutines */

inline void setmax(double &a, double b) { if (a < b) a = b; }

/* main */

int main() {
  int n, m;
  scanf("%d%d", &n, &m);

  asums[0] = 0;
  for (int i = 0; i < n; i++)
    scanf("%d", as + i), asums[i + 1] = asums[i] + as[i];

  for (int i = 0; i <= n; i++)
    fill(dp[i], dp[i] + m + 1, -1.0);
  dp[0][0] = 0.0;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (dp[i][j] >= 0.0)
	for (int k = i + 1; k <= n; k++) {
	  double d = dp[i][j] + (double)(asums[k] - asums[i]) / (k - i);
	  setmax(dp[k][j + 1], d);
	}

  printf("%.6lf\n", dp[n][m]);
  return 0;
}



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

using namespace std;

int n, a[200], ans;

int main(){
	cin >> n;
	for(int i = 0; i < 2 * n; ++i){
		cin >> a[i];
		}
	sort(a, a + 2 * n);
	for(int i = 0; i < 2 * n; i += 2){
		ans += min(a[i], a[i + 1]);
		}
	cout << ans << endl;
	return 0;
	}


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

#define nguyendz the_best
using namespace std;

#define ll long long
#define endl "\n"
#define ld long double
#define pb push_back
#define all(n) n.begin(),n.end()
#define eb emplace_back
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define ff first
#define ss second
#define setpre(x) fixed<<setprecision(x)


const ll maxn=1e3+2;

const ll maxx=1e13;
const ll mod1=1000000007;
const ll mod=998244353;
const ll base=31;
//priority_queue<pll,vector<pll>,greater<pll>> q;
set<ll> adj[maxn];
vector<ll> adj1[maxn];
/*do not use "\n" in interactive problem
((x|y)-y) (x&(~y))
__gcd(fibo(x),fibo(y)=fibo(__gcd(x,y))
so luong tap hop gom d phan tu khac nhau dc tao tu k so phan biet la k mu d
a+b=(a^b)+2*(a&b)
giai 1 bai toan ve n cac cap (xi,yi) ta thuong swap(xi,yi) neu xi>yi ,  sort theo x1 roi chay tu i->n va tim max hoac min 1-> i-1 cua yi dua tren DK:(xi<yi)
log10(n^k)=k*log10(n)
so chu so cua n = (ll)(log10(n))+1*/
ll mp[maxn][maxn];
ll cnt=0;


vector<pll> bri;
vector<string> s;

 ll n,m;
bool y=false;
ll dd[maxn];
void dfs(ll u,ll bd)
{
    for (auto to:adj[u])
    {
        if (mp[to][u])
        {
            cnt++;
            mp[to][u]=0;
            mp[u][to]=0;
            if (cnt==m)
            {
                if (bd==to)
                {
                    //cout <<bd<<endl;
                   // cout <<m<<endl;
                    y=true;
                }
            }
            dfs(to,bd);
            break;
        }
    }
}

void dfs1(ll u)
{
    dd[u]=1;
    for (auto to:adj[u])
    {
        if (!dd[to])
        {

            dfs1(to);
        }
    }
}
int main()
{
    // freopen("test.txt","r",stdin);
    //  freopen("Bridge2P.OUT","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

   ll n;
   cin>>n;
   ll k=n/500;
   ll cnt=k*1000;
   n%=500;
   ll k1=n/5;
   cnt+=k1*5;
   cout <<cnt;
    /*
    5 5
1 3
2 5
1 4
3 5
2 4
1 3
1*/

}


Measured memory_bytes: 384
using System;
using System.Linq;
namespace ABC144_C
{
    class Program
    {
        static long N;
        static void Main(string[] args)
        {
            N = long.Parse(Console.ReadLine());
            Console.WriteLine(Dfs("0"));
        }

        static long Dfs(string s){
            long ret = 0;

            if(long.Parse(s) > N){
                return 0L;
            }
            if(s.Contains("3") && s.Contains("5") && s.Contains("7")){
                ret = 1;
            }
            foreach(var i in new char[]{'3','5','7'}){
                ret += Dfs(s + i);
            }

            return ret;
        }
    }
}


Measured memory_bytes: 17228
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int N, Q;
    cin >> N >> Q;
    
    string S;
    cin >> S;

    vector<int> cnt(N);
    if (S[0] == 'A' && S[1] == 'C') cnt[0] = 1;
    for(int i = 1; i < N; i++) {
        cnt[i] = cnt[i-1];
        if (i&&S[i] == 'C' && S[i-1] == 'A') {
            cnt[i] += 1;
        }        
    }

    vector<pair<int, int>> a(Q);
    for(int i = 0; i < Q; i++) {
        cin >> a[i].first >> a[i].second;
        a[i].first--; a[i].second--;
    }

    for(int i = 0; i < Q; i++) {
        cout << cnt[a[i].second] - cnt[a[i].first] << endl;
    }

}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll now = INF, ans, n;
set<ll> s;
int main() {
	cin >> n;
	REP(i, n) {
		ll a;
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;
}




Measured memory_bytes: 7756
#include <atcoder/dsu>
#include <iostream>

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

using namespace std;
using namespace atcoder;

int main(void) {
    int n, q;
    cin >> n >> q;

    dsu uf(n);

    rep(loop, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t) {
            cout << uf.same(u, v) << endl;
        } else {
            uf.merge(u, v);
        }
    }

    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

ll mpow(ll x, ll n, ll mod){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % mod;
        x = x * x % mod;
        n  = n >> 1;
    }
    return ans;
}

int main(){
    ll X;
    cin >> X;
    ll ans = 100;
    rep(i, 4000){
        ans *= 1.01;
        if(ans >= X){
            cout << i + 1 << endl;
            return 0;
        }
    }
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;
const int mxn=1000;
char a[mxn+1][mxn+1];
int dp[mxn+1][mxn+1];
int h,w;
void solve()
{ 
  cin>>h>>w;
  for(int i=1;i<=h;i++)
  {
    for(int j=1;j<=w;j++)
    {
      cin>>a[i][j];
    }
  }

  for(int i=1;i<=h;i++)
  {
    for(int j=1;j<=w;j++)
    {
       if(i==1 && j==1)
        {dp[1][1]=1;
          continue;
        }
      if(a[i][j]=='#')
        continue;
      dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    }
  }
  cout<<dp[h][w]<<endl;
  
}
int main()
{
  fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string T;
ll p3[13];
ll P[540000];
ll D[540000];
int F[540000];
ll W[14][540000];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	p3[0]=1;
	FOR(i,N) p3[i+1]=p3[i]*3;
	
	for(i=1;i<=N;i++) {
		FOR(x,p3[i]) D[x]=x/p3[i-1];
		W[i][0]=p3[i]-1;
		ZERO(F);
		int nf=0;
		FOR(x,T.size()) {
			if(T[x]=='S') {
				nf++;
			}
			else {
				y=W[i-1][x];
				if((nf-F[y])%2) {
					FOR(j,3) {
						if(D[y+j*p3[i-1]]==1) D[y+j*p3[i-1]]=2;
						else if(D[y+j*p3[i-1]]==2) D[y+j*p3[i-1]]=1;
					}
					F[y]=nf;
				}
				FOR(j,3) {
					D[y+j*p3[i-1]]=(D[y+j*p3[i-1]]+1)%3;
				}
			}
			y=W[i-1][x+1];
			if((nf-F[y])%2) {
				FOR(j,3) {
					if(D[y+j*p3[i-1]]==1) D[y+j*p3[i-1]]=2;
					else if(D[y+j*p3[i-1]]==2) D[y+j*p3[i-1]]=1;
				}
				F[y]=nf;
			}
			FOR(j,3) if(D[y+j*p3[i-1]]==2) W[i][x+1]=y+j*p3[i-1];
		}
		
		
		FOR(y,p3[i-1]) {
			if((nf-F[y])%2) {
				FOR(j,3) {
					if(D[y+j*p3[i-1]]==1) D[y+j*p3[i-1]]=2;
					else if(D[y+j*p3[i-1]]==2) D[y+j*p3[i-1]]=1;
				}
			}
		}
		FOR(x,p3[N]) P[x]+=D[x%p3[i]]*p3[i-1];
	}
	
	FOR(i,p3[N]) {
		cout<<P[i]<<" ";
	}
	cout<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 33668