akhauriyash/Code-Regression huggingface dataset:
package main
// 3人でカードゲーム
import (
	"fmt"
	"bufio"
	"os"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func readStr() []string {
	sc.Scan()
	return strings.Split(sc.Text(), "")
}

func pop(slice []string) (string, []string) {
	next := slice[0]
	return next, slice[1:]
}

func main() {
	a, b, c := readStr(), readStr(), readStr()
	n := "a"
	L:
		for {
			switch n {
			case "a":
				if len(a) == 0 {
					fmt.Println("A")
					break L
				}
				n, a = pop(a)
			case "b":
				if len(b) == 0 {
					fmt.Println("B")
					break L
				}
				n, b = pop(b)
			case "c":
				if len(c) == 0 {
					fmt.Println("C")
					break L
				}
				n, c = pop(c)
			}
		}
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define Mod 1000000007
#define REP(i,a,b) for (int i = a; i <= b; i++)

vector<vector<int>>v(202020);
vector<int>ans(202020,0);
void dfs(int i,int n){
    for(int j=0;j<v[i].size();j++){
        ans[v[i][j]]+=ans[i];
        dfs(v[i][j],n);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q; cin>>n>>q;
    
    for(int i=0;i<n-1;i++){
        int x,y; cin>>x>>y;
        v[x].push_back(y);
    }
    
    for(int i=0;i<q;i++){
        int x,y; cin>>x>>y;
        ans[x]+=y;
    }
    dfs(1,n);
    for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
    return 0;
}


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

#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;

map<int, int> mp;
int N, M;

void dfs(vector<vector<int>> &A, int node, int &count){

	if(mp[node] == 1)return;
	mp[node] = 1;

	bool b = true;
	for(int i = 0; i < N; ++i){
		if(mp[i] == 0){b = false;break;}
	}

	if(b)++count;

	for(int i = 0; i < A[node].size(); ++i){
			dfs(A, A[node][i], count);
	}

	mp[node] = 0;
}

int main() {
	cin >> N >> M;

	vector<vector<int>> A(N + 1, vector<int>(0));

	for(int i = 0; i < M; ++i){
		int a, b;
		cin >> a >> b;
		A[a - 1].push_back(b - 1);
		A[b - 1].push_back(a - 1);
	}

	int count = 0;
	mp[0] = 1;
	for(int i = 0; i < A[0].size(); ++i){
		dfs(A, A[0][i], count);
	}

	cout << count << endl;


	return 0;
}


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

int main(){
  long X;
  cin >> X;
  long maxN = X/100;
  X %= 100;
  int v1=1, v2=2, v3=3, v4=4, v5=5;
  if(X <= 5*maxN) cout << 1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 256
N = int(input())
a = [int(input()) -1 for _ in range(N)]

done = [False]*N
i = 0
cnt = 0

while True:
    if done[i] == False:
        done[i] = True
        cnt += 1
        if a[i] == 1:
            break
        i = a[i]
    else:
        cnt = -1
        break

print(cnt)

Measured memory_bytes: 7852
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  ll N,M; cin >> N >> M;
  if ( N==1 && M== 1 ) {
    cout << 1 << endl;
    return 0;
  }
  
  if ( N == 1 || M == 1 ) {
    if ( N == 2 || M == 2 ) cout << 0 << endl;
    else if ( N >= 3 || M >= 3 ) cout << max(N,M)-2 << endl;
    return 0;
  } 

  if ( N  == 2 || M == 2 ) {
    if ( N ==1  || M == 1 ) cout << 0 << endl;
    else if ( (N == 2 && M == 2) || (M == 2&& N == 2)) cout << 0 << endl;
    else cout << 0 << endl;
    return 0;
  }
  
  cout << (N-2) * (M-2) << endl;
  return 0;
}


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

using namespace std;

int main(){

  int n,m;

  cin >> n;
  cin >> m;

  vector<int> a(m);

  for(int i=0;i < m;++i)
	cin >> a[i];

  int cnt = 0;
  int num = 1;
  
  for(int i=0;i < m;++i){
	if(a[i] != num){
	  cnt++;
	  m--;
	  num++;
	  i--;
	}
	else
	  num++;
  }

  cout << cnt << endl;
  
}



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

using namespace std;

long long mpow(long long n, long long m, long long mod) {
  unsigned long long ret = 1;
  for (; m>0; m>>=1) {
    if(m&1) ret=ret*n%mod;
    n=n*n%mod;
  }
  return ret;
}

unsigned long long *flist, *mlist;

void combinations_base(unsigned long long n, unsigned long long mod) {
  flist = new unsigned long long[n+1];
  mlist = new unsigned long long[n+1];

  flist[0]=mlist[0]=1;
  for (unsigned long long i=1; i<=n; i++) {
    flist[i] = flist[i-1] * i % mod;
    mlist[i] = mpow(flist[i], mod-2, mod);
  }
}

unsigned long long combinations(unsigned long long n, unsigned long long k, unsigned long long mod) {
  unsigned long long ret;
  // combinations_base(n, mod);

  ret = flist[n] * mlist[k];
  ret %= mod;
  ret = ret * mlist[n-k];
  ret %= mod;

  // delete[] flist;
  // delete[] mlist;

  return ret;
}

int main() {
  unsigned long long N,K;
  unsigned long long mod=1000000007;
  cin >> N >> K;
  combinations_base(N, mod);
  for(int i=1; i<=K; i++) {
    unsigned long long int ans;

    if (N-K+1 < i) ans = 0;
    else {
      ans = combinations(N-K+1, i, mod)*combinations(K-1, i-1, mod);
      ans %= mod;
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

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

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}

//int ()



int main()
{
  int  a ,b, c, d, e, X, Y ,r;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
//  int  A[200003]={};
  int  A[100003]={};
  int  B[100003]={};
  int  C[100003][11]={};

  int  flg=0;

//  long long  a, b, c, d, X, Y;
//  char s[101][101]={};
  char s[100001]={};
  char t[101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  int ans=0;
  int max=0;
  int sum=0;
  int addr=0;
  int ptn=0;
  long long  tmp=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d", &a);
  scanf("%c", &s[0]);
  
  for(i=0;i<a;i++){
    scanf("%c", &s[1]);
//    printf("%c\n", s[1]);
    if(s[0]!=s[1]){
      cnt++;
      s[0]=s[1];
    }
    

  }
  printf("%d\n", cnt);
  
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int W[310000], E[310000];
int main()
{
  int N;
  string S;
  cin >> N >> S;

  // 値の設定
  for (int i = 0; i < N; i++) {
    if (S[i] == 'W') W[i] = 1;
    else  E[i] = 1;
  }

  // 累積
  for (int i = 0; i < N; i++) {
    W[i + 1] += W[i];
    E[i + 1] += E[i];
  }

  int ans = 1100000000;
  for (int i = 0; i < N; i++) {
    int lW = W[i];
    int lE = E[i];
    int rE = E[N-1] - E[i];
    if (S[i] == 'W') lW--;
    else lE--;
    ans = min(ans, lW + rE);
  }
  cout << ans << endl;

  return 0;
}

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

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& s,const vector<T>& v)
{s<<"{";if(SZ(v))s<<join(v,", ");s<<"}";return s;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    string S; cin >> S;
    
    if (contain(S, "AA")) {
        cout << "NO" << endl;
        return 0;
    }
    if (contain(S, "KA")) {
        cout << "NO" << endl;
        return 0;
    }
    if (contain(S, "IA")) {
        cout << "NO" << endl;
        return 0;
    }
    
    replace(S, "A", "");
    
    if (S == "KIHBR") cout << "YES" << endl;
    else cout << "NO" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  char c;
  cin >> c;
  char l = c - 'a';
  if (l >= 0 && l <= 'z' - 'a')
  {
    cout << "a" << endl;
  } else {
    cout << "A" << endl;
  }
  return 0;
}

Measured memory_bytes: 3604
def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False
    return pow(2, q-1, q) == 1

while(True):
    try:
        a = int(raw_input())
    except:
        break
    b = a
    
    while(True):
        b -= 1
        if(is_prime(b)):
            print b ,
            break

    while(True):
        a+=1
        if(is_prime(a)):
            print a
            break

Measured memory_bytes: 4220
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <array>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    long long s;
    cin >> s;
    long x1, y1, x2, y2, x3, y3;
    x1 = 0;
    y1 = 0;
    x2 = 1000000000;
    y2 = 1;
    long x = s % 1000000000;
    long y = s / 1000000000;
    x3 = 1000000000 - x;
    y3 = y + 1;
    if(y3 > 1000000000){
        y3 = y;
        x3 = y*1000000000 - s;
    }
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << " " << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

int main(int argc, const char* argv[]) {
  u64 a, b, k;
  cin >> a >> b >> k;
  
  for(u64 i = min(a, b); i > 0; --i) {
    if(((a % i) == 0) && ((b % i) == 0)) {
      --k;
      if(k == 0) {
        cout << i << endl;
        return 0;
      }
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
STR = input()
q = int(input())

for i in range(q):
    order = input().split()
    op = order[0]
    a = order[1]
    b = order[2]
    a = int(a)
    b = int(b)

    if op == "replace":
        p = order[3]
        STR = STR[:a] + p + STR[b+1:]
    elif op == "reverse":
        re_STR = STR[a:b+1]
        STR = STR[:a] + re_STR[::-1] + STR[b+1:]
    elif op == "print":
        print(f"{STR[a:b+1]}")



Measured memory_bytes: 5616
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int N,D;
    int cnt=0;
    scanf("%d%d",&N,&D);
    int ten[N][D];
    rep(i,N){
        rep(j,D){
            scanf("%d",&ten[i][j]);
        }
    }
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            int temp=0;
            for(int k=0;k<D;k++){
                temp+=(ten[i][k]-ten[j][k])*(ten[i][k]-ten[j][k]);
            }
            for(int m=1;m<=16000;m++){
                if(temp==m*m){
                    cnt++;
                }
            }
        }
    }
    printf("%d",cnt);
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
# define M_PI           3.14159265358979323846
int main(){
	double a, b, x;
	cin>>a>>b>>x;
	cout<<setprecision(10);
	if(x <= (a * a * b) / 2.0){
		x = (double)(x / a);
		x *= 2.0;
		x = (double)(x / b);
		cout<<(double)(atan2(b, x) * 180.0) / M_PI<<endl;
	}
	else{
		double t = (a * a * b) - x;
		t /= a;
		t *= 2;
		t /= a;
		cout<<90.0 -(double)(atan2(a, t) * 180.0) / M_PI<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9)
    {
        cout << "-1" << endl;
    }
    else
    {
        cout << a * b << endl;
    }
}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    int ans = 0;
    if (w % 2 == 0 && w / 2 == x && h % 2 == 0 && h / 2 == y) ans = 1;
    printf("%.15f %d\n", 1.0 * w * h / 2, ans);
}


Measured memory_bytes: 3768
using System;
using System.Runtime.Remoting.Contexts;

namespace Contest
{

    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private string S;
        private void Scan()
        {
            Scanner sc = new Scanner();
            S = sc.Next();
        }


        public void Solve()
        {
            Scan();
            bool flagA = false;
            int cntC = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if ('A' <= S[i] && S[i] <= 'Z')
                {
                    if (i == 0 && S[i] == 'A')
                    {
                        flagA = true;
                    }

                    else if (2 <= i && i <= S.Length - 2 && S[i] == 'C')
                    {
                        cntC++;
                    }
                    else
                    {
                        Console.WriteLine("WA");
                        return;
                    }
                }
                else if ('a' <= S[i] && S[i] <= 'z')
                {

                }
                else
                {
                    Console.WriteLine("WA");
                    return;
                }
            }

            if (flagA && cntC == 1)
            {
                Console.WriteLine("AC");
            }
            else
            {
                Console.WriteLine("WA");
            }
        }

        static void Main() => new Program().Solve();
    }
}

Measured memory_bytes: 11092
// Author: Zark84010 (Aditya Ranjan)

#include <bits/stdc++.h>
 
using namespace std;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"
 
#define sz(a) ((int)(a).size())
#define all(v) (v).begin(), (v).end()
#define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
#define pres(c, val) ((c).find(val) != (c).end())      //
#define cpres(c, val) (find(all(c), val) != (c).end()) //

#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define forf(i, a, b) for (int i = (a); i < (b); i++)
#define forb(i, a, b) for (int i = (b); i >= (a); i--)
#define fo(i, n) forf(i, 0, n)
#define fob(i, n) forb(i, 0, n - 1)
 
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vpii;
 
const int INF = 9e18;
const int N = 1e9 + 7;
// const int N = 998244353;
const double eps = 1e-9;
 
const auto start_time = std::chrono::high_resolution_clock::now();
 
void zark() {
  #ifdef ZARK
  	auto end_time = std::chrono::high_resolution_clock::now();
  	std::chrono::duration<double> diff = end_time - start_time;
  	cerr << "Time Taken : " << diff.count() << "s\n";
  #endif
}
 
#ifdef ZARK
	#include "/home/aranjan/Desktop/CP/header.h"
	#else
	#define dbg(args...)
#endif

/* ------------------ Actual Coding Starts ------------------ */

void solve() {
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	int ans = 0;
	if(k <= a) {cout << k << endl; return;}
	else ans += a, k-=a;
	if(k <= b) {cout << ans << endl; return;}
	else k -= b;
	cout << ans - k << endl;
}

int32_t main() {
  fastio;
  #ifdef ZARK
  freopen("input.in", "r", stdin);
  #endif
 
  // freopen("txt.in", "r", stdin);
  // freopen("txt.out", "w", stdout);
  // cout << fixed << setprecision(35);
 
 	solve();
  zark();
  return 0;
}

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

namespace COJ1_7
{
    struct Node
    {
        public int parent;
        public int sibling;
        public int degree;
        public int depth;
        public int height;
        public string type;
        public int left;
        public int right;

    }
    class Program
    {
       
        static void Main(string[] args)
        {
            int cnt;
            Node[] nodes;

            cnt = int.Parse(Console.ReadLine());
            nodes = new Node[cnt];

            for(int i = 0; i < cnt; i++)
            {
                nodes[i].parent = -1;
                nodes[i].sibling = -1;
            }

            for(int i = 0; i < cnt; i++)
            {
                var param = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                int index = param[0];
                int left = param[1];
                int right = param[2]; 
                nodes[index].left = left;
                nodes[index].right =right;
                if (left != -1)
                {
                    nodes[left].parent = index;
                    nodes[left].sibling = right;
                }
                if (right != -1)
                {
                    nodes[right].parent = index;
                    nodes[right].sibling = left;
                }
                if (left != -1 && right != -1)
                {
                    nodes[index].degree = 2;
                    nodes[index].type = "internal node";
                }
                else if (left != -1 || right != -1)
                {
                    nodes[index].degree = 1;
                    nodes[index].type = "internal node";
                }
                else
                {
                    nodes[index].degree = 0;
                    nodes[index].type = "leaf";
                }
            }
            for(int i = 0; i < cnt; i++)
            {
                if (nodes[i].parent == -1)
                {
                    nodes[i].type = "root";
                    GetDepth(nodes, i, 0);
                }
            }

            StringBuilder builder = new StringBuilder();
            for(int i = -0; i < cnt; i++)
            {
                builder.Append("node ").Append(i).Append(": ").Append("parent = ").Append(nodes[i].parent).Append(", sibling = ").Append(nodes[i].sibling).Append(", degree = ").Append(nodes[i].degree).Append(", depth = ").Append(nodes[i].depth).Append(", height = ").Append(nodes[i].height).Append(", ").Append(nodes[i].type).Append("\n");
            }
            Console.Write(builder.ToString());
        }
        public static int GetDepth(Node[] nodes, int i, int depth)
        {
            if (i == -1) return -1;
            nodes[i].depth = depth;
            nodes[i].height=Math.Max(GetDepth(nodes, nodes[i].left, depth + 1)+1, GetDepth(nodes, nodes[i].right, depth + 1)+1);
            return nodes[i].height;
        }
    }
}

Measured memory_bytes: 9180
N,K = map(int,input().split())
lst = []
for i in range(K):
    d = int(input())
    sunuke = list(map(int,input().split()))
    n = 0
    while n < d:
        lst.append(sunuke[n])
        n += 1
moratta = len(set(lst))
print(N - moratta)

Measured memory_bytes: 9192
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

m = min([A, B, C, D, E])

if N % m == 0:
    print(5 + (N // m) - 1)
else:
    print(5 + (N // m))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long


void solve(long long N, std::string S){
    for (int i = 0; i < S.size(); ++i) {
        S[i] = (S[i] - 'A' + N) % 26 + 'A';
    }
    cout << S << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;
#define MAX_N 100000
#define INF 100000000000
ll dp[MAX_N];

void init(){
	rep(i,MAX_N){
		dp[i] = INF;
	}
}


int main()
{
	init();
	int n;
	cin>>n;
	ll *a = new ll[n];
	rep(i,n){
		cin>>a[i];
	}
	for(int i = 0; i < n; i++){
		*lower_bound(dp,dp + n,a[i]) = a[i];
	}
	cout<<lower_bound(dp,dp + n,INF) - dp<<endl;
	return 0;
}




Measured memory_bytes: 4640
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
using namespace std;
constexpr int64_t INF = 1000000000;

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

  int32_t a,b;
  cin >> a >> b;
  int res = 0;
  if (a > b) {
    res = b;
    a--;
    while (a) {
      res = 10*res + b;
      a--;
    }
  } else {
    res = a;
    b--;
    while (b) {
      res = 10*res + a;
      b--;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		
		int x=cin.nextInt(),y=cin.nextInt();
		int m=x,n=y,k=x*y;
		
		while(k!=0) {
			 k=m%n;
			 m=n;n=k;
		}
		System.out.println(m);
	}

}



Measured memory_bytes: 26264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    string S;
    cin >> S;
    int ans = 0;
    int now = 0;
    rep(i,3){
        if(S[i] == 'R') now++;
        if(S[i] == 'S'){
            now = 0;
        }
        ans = max(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
n = int(input())
s = input()
r_ary = []
g_ary = []
b_ary = []
for i in (s):
    if i == 'R':
        r_ary.append(i)
    elif i == 'G':
        g_ary.append(i)
    elif i == 'B':
        b_ary.append(i)
r = len(r_ary)
g = len(g_ary)
b = len(b_ary)
first_conditions = r*g*b
for i in range(n-2):
    for j in range(i+1,n-1):
        if 2*j-i<n and s[i]!=s[2*j-i] and s[j]!=s[2*j-i] and s[i]!=s[j]:
            first_conditions -= 1
print(first_conditions)

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

int main() {
  int a,b,k;
  int cnt=0,ans=0;

  cin >> a >> b >> k;

  for(int i=min(a,b);i>0;i--) {
    if(a%i==0&&b%i==0) {cnt++;}
    if(cnt==k) {ans=i;break;}
  }

  cout << ans << endl;

  return 0;
}


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

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

using namespace std;
using ll = long long;
int mod = 1000000007;

int num[3] = {0, 0, 0};
void add(){
    if(num[2] == 9 && num[1] == 9){
        num[0] += 1; num[1] = 0; num[2] = 0;
    }
    else if(num[2] == 9){
        num[1] += 1; num[2] = 0;
    }
    else num[2] += 1;
}

int main(void){
    int N; cin >> N;
    string S; cin >> S;
    for(int i = 0; i < 30000; i++) S += "1";
    int cnt = 0;
    for(int i = 0; i < 1000; i++){
        int idx = 0;
        for(int j = 0; j < N; j++){
            if(S[j] - '0' == num[idx]){
                idx++;
                if(idx == 3) break;
            }
        }
        if(idx == 3) cnt++;
        add();
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;
int main()
{
    int n, x, y, t, pt = 0, px = 0, py = 0, f = 1;
    cin>>n;
    while(n--)
    {
        cin>>t>>x>>y;
        int man = (abs(px-x)+abs(py-y));
        if(man > t-pt)
            f = 0;
        if(t-pt > man&&(t-pt-man)%2)
            f = 0;
        px = x, py = y, pt = t;
    }
    if(f)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

tmp = min(A,B,C,D,E)
if N % tmp == 0:
    ans = N // tmp
else:
    ans =  N // tmp + 1

print(ans+4)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
	in >> p.first >> p.second;
	return in;
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD = 1e9 + 7;
	string s;
	cin>>s;
	rep(i,s.size())cout<<'x';
	cout<<endl;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int N = saori.saori_hayami();
		int W = saori.saori_hayami();
		int[] w = new int[N];
		int[] v = new int[N];
		for(int i = 0; i < N;i++){
			w[i] = saori.saori_hayami();
			v[i] = saori.saori_hayami();
		}
		long[][] dp = new long[w.length+1][W+1];

		for(int i = 0; i < w.length;i++){
			for(int j = 0; j <= W;j++){
				dp[i+1][j] = Math.max(dp[i + 1][j], dp[i][j]);
				if(j - w[i] >= 0){
					dp[i+1][j] = Math.max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
				}
			}
		}
		System.out.println(dp[w.length][W]);

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;

#define ll long long 
#define REPL(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
static const int MAX = 10010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;
static const ll MOD = 1000000007;


int main() {

  int N = 0;
  string S;

  cin >> N;
  cin >> S;

  REP(i, S.length()){
    S[i] += N;
    if( (int)S[i] > 90  ){
      S[i] = S[i] - 90 + 64;
    }
  }
  
cout << S << endl;

  return 0;

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


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


int main() {
    long long A, B; cin >> A >> B;
    long long X = A * B;

    if (A < B) swap(A, B);

    long long r = A % B;
    while (r != 0) {
        A = B;
        B = r;
        r = A % B;
    }

    cout << X / B << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    string S;
    cin >> S;

    vi a1(N+2), a2(N+2);
    
    FOR(i, 1, N) {
        a1[i] = a1[i-1];    // 前の項を引き継いでから1足すか否か判断する．
        if(S[i-1] == 'W') ++a1[i];
    }
    for(int i = N - 2; i >= 0; --i) {
        a2[i] = a2[i+1];
        if(S[i+1] == 'E') ++a2[i];
    }
    int ans = 1000000000;
    FOR(i, 0, N) ans = min(ans, a1[i] + a2[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2964
<?php
$s = trim(fgets(STDIN));
$l = strlen($s);

$ans = true;
for ($i=0; $i < $l; $i++) { 
	$tmp = $s[$i];
	$res = false;
	if ($i % 2 === 0) {
		if(in_array($tmp, ['R','U','D'])){
			$res = true;
		}
	}else{
		if(in_array($tmp, ['L','U','D'])){
			$res = true;
		}
	}
	$ans = ($ans && $res);
}

if ($ans) {
	echo 'Yes';
}else{
	echo 'No';
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll INF = (1ll<<60);
ll dp[3030][3030];
vector<ll> a(3030);
ll N;

ll rec(ll L, ll R){
	if(dp[L][R]>-INF) return dp[L][R];
	if(L==R) return 0;

	ll res;
	if((R-L)%2 == N%2){
		// taro
		res = -INF;
		res = max(res, rec(L+1, R)+a[L]);
		res = max(res, rec(L, R-1)+a[R-1]);
	}else{
		// jiro
		res = INF;
		res = min(res, rec(L+1, R)-a[L]);
		res = min(res, rec(L, R-1)-a[R-1]);
	}

	dp[L][R] = res;
	return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    REP(i, 3030)REP(j, 3030) dp[i][j] = -INF;

    cin >> N;
    REP(i, N) cin >> a[i];

    cout << rec(0, N) << endl;
    return 0;
}

Measured memory_bytes: 72192
def nex(x,m):
    for c in range(len(x)-1,-1,-1):
        if x[c]<m:
            x[c]+=1
            for d in range(c+1,len(x)):
                x[d]=x[c]
            return x
    return -1


n,m,q=map(int,input().split())
f=[]
for i in range(q):
    f.append([int(x) for x in input().split()])

s=0
a=[1]*n
while True:
    if a==-1:
        break
    p=0
    for i in range(q):
        if a[f[i][1]-1]-a[f[i][0]-1]==f[i][2]:
            p+=f[i][3]
    if p>s:
        s=p
    a=nex(a,m)
print(s)

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();
		scan.close();

		char c[] = str.toCharArray();
		int cnt=0;
		for(int i=0;i<c.length/2;i++) {
			if(c[i]!=c[c.length-1-i]) {
				cnt++;
			}
		}

		System.out.println(cnt);

	}

}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i, n) cin >> vec.at(i);
  int mini = 1000000;
  for(int i = 1; i <= 100; i++) {
    int sum = 0;
    rep(j, n) sum += pow(vec.at(j)-i, 2);
    mini = min(mini, sum);
  }
  cout << mini << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readFloat64() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func main() {
	a, b := readFloat64(), readFloat64()
	switch {
	case a == b:
		fmt.Println("EQUAL")
	case a > b:
		fmt.Println("GREATER")
	case a < b:
		fmt.Println("LESS")
	}
}


Measured memory_bytes: 640
import java.util.*;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int ans = -1;
    for (int i = 1; i < 1009; i++) {
      if (Math.floor(i * 0.08) == A && Math.floor(i * 0.1) == B) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23872
import java.io.*;
import java.util.*;

class Main{
	int max = 0;
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		int[] d = new int[n];
		boolean[] judge = new boolean[n];
		Arrays.fill(judge, true);
		int count = 0;
		for(int i=0;i<n;i++){
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for(int i=0;i<n;i++){
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(a[i]>a[j]){
					int tmp = a[i];
					a[i] = a[j];
					a[j] = tmp;
					tmp = b[i];
					b[i] = b[j];
					b[j] = tmp;
				}
				else if(a[i]==a[j] && b[i]>b[j]){
					int tmp = a[i];
					a[i] = a[j];
					a[j] = tmp;
					tmp = b[i];
					b[i] = b[j];
					b[j] = tmp;	
				}
				if(c[i]>c[j]){
					int tmp = c[i];
					c[i] = c[j];
					c[j] = tmp;
					tmp = d[i];
					d[i] = d[j];
					d[j] = tmp;
				}
				else if(c[i]==c[j] && d[i]>d[j]){
					int tmp = c[i];
					c[i] = c[j];
					c[j] = tmp;
					tmp = d[i];
					d[i] = d[j];
					d[j] = tmp;
				}
			}
		}
		for(int i=0;i<n;i++){
			int now = -1;
			int y = -1;
			for(int j=0;j<n;j++){
				if(!judge[j]){
					continue;
				}
				if(a[j]<c[i] && b[j]<d[i]){
					if(y<b[j]){
						now = j;
						y = b[j];
					}
				}
			}
			if(now!=-1){
				count++;
				judge[now] = false;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 24020
//bismillah
//author anaksoleh
//26 Dec 2019
#include <bits/stdc++.h>
using namespace std;

const int SIZE = 1e5 + 5;
int N;
bool computed[SIZE][4];
int memo[SIZE][4];
int arr[SIZE][4];

int solve(int row,int col)
{
    if(row == 1)return arr[row][col];
    if(computed[row][col])return memo[row][col];

    int best = 0;
    for(int i = 1 ; i <= 3 ; i++){
        if(i == col)continue;
        best = max(best,solve(row-1,i) + arr[row][col]);    
    }
    memo[row][col] = best;
    computed[row][col] = true;
    return best; 
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    for(int i = 1 ; i <= N ; i++){
        cin >> arr[i][1] >> arr[i][2] >> arr[i][3];
    }
    int ans = 0;
    for(int i = 1 ; i <= 3 ; i++) ans = max(ans,solve(N,i));
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 11648
#include<iostream>
using namespace std;
#include<vector>
#define re(i,n) for(int i = 0; i < n; i++)
const int MOD = 1000000007;

long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main() {
    int k;
    cin >> k;
    re(i, k)cout << "ACL";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3496
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define int ll
using pint = pair<int,int>;
using Graph = vector<vector<int>>;
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 1e10; //10^10
const double PI = acos(-1.0L);
/*mod逆元*/long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template< typename T >T mod_pow(T x, T n, T p=MOD) {T ret = 1;while(n > 0) {if(n & 1) (ret *= x) %= p;(x *= x) %= p;n >>= 1;}return ret;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}

//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    int all = 1 , sub = 1;
    REP(i,n){
        int a; cin >> a;
        all *= 3;
        if(a&1) sub *= 1; //奇数だったら2つOK → 1つ除く
        else sub *= 2; //偶数だったら1つOK → 2つ除く
    }
    out(all-sub);

    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

void solve()
{
  ll n; cin >> n;
  vector<ll> a(n); REP(i, n) cin >> a[i];
  ll ans = 0;
  sort(a.begin(), a.end());
  ll i = 0;
  while(i < n) {
    ll a1 = a[i];
    ll cnt = 0;
    while(i < n && a[i] == a1) {
      cnt ++; i++;
    }
    //    cout << a1 << " " << cnt << endl;
    if(cnt > a1) {
      ans += cnt - a1;
    } else if(cnt < a1) {
      ans += cnt;
    }
  }
  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


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

int main() {
    int K;
    string S;
    cin >> K;
    cin >> S;
    
    if(S.size() <= K){
        cout << S << endl;
    }else{
        cout << S.substr(0,K) + "..." << endl;
    }

	return 0;
}

Measured memory_bytes: 3628
#include<stdlib.h>
#include<stdio.h>

int compare(const void* s,const void *t ){
  return (*((int*)t) - *((int*)s));
}

int main(){
  int height[10];
  int i=0;
  while(~scanf("%d",&height[i++]));
  qsort(height, 10, sizeof(height[0]), compare );
  for( i = 0; i < 3 ; i++ )
    printf("%d\n",height[i]);
  return 0;
}

Measured memory_bytes: 1032
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#include<bits/extc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
const ll mod = 998244353;
using oset = tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll fact[10001001], inv[10001001], p3[10001001];
ll bp(ll a, ll p) {
	ll res = 1;
	while(p) {
		if(p&1) res = (res*a)%mod;
		a=(a*a)%mod;
		p>>=1;
	}
	return res;
}
ll nck(ll n, ll k) {
	ll res = (fact[n]*inv[k])%mod;
	return (res*inv[n-k])%mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	fact[0]= p3[0] = 1;
	for(int i = 1; i <= 10000000; i++)
		fact[i] = (fact[i-1]*i)%mod;
	inv[10000000]=bp(fact[10000000], mod-2);
	for(int i = 10000000; i--;)
		inv[i] = (inv[i+1]*(i+1))%mod;
	for(int i = 1; i <= 10000000; i++)
		p3[i] = (p3[i-1]*2)%mod;
	ll ans = bp(3, n);
	for(ll x = (n/2)+1; x <= n; x++) {
		ans = (mod+ans - (2ll*p3[n-x]*nck(n, x))%mod)%mod;
	}
	cout << ans;
}


Measured memory_bytes: 234624
#include <iostream>
#define MAX 100
using namespace std;

int main(){
	int N, T[MAX], M, P[MAX], X[MAX];
	int orig = 0;
	cin >> N;
	for (int i=0; i<N; ++i) {
		cin >> T[i];
		orig += T[i];
	}
	cin >> M;
	for (int i=0; i<M; ++i) {
		cin >> P[i] >> X[i];
		cout << orig - T[P[i]-1] + X[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>

double n;

int main() {
    std::cin >> n;
    int a = std::sqrt(n);
    double b = 0;
    for (int i = a; i > 0; i--) {
        if (std::fmod(n, i) == 0) {
            b = n / i;
            break;
        }
    }
    int digit = 0;
    while (b >= 1) {
        b /= 10;
        digit++;
    }
    std::cout << digit << std::endl;
}

Measured memory_bytes: 256