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

using namespace std;

const int MaxN = 303;

long double p[MaxN][MaxN][MaxN];
long double ev[MaxN][MaxN][MaxN];

long double cost(long double p)
{
    return p / (1. - p);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    int n;
    cin >> n;

    int cnt[4] ({});

    for(int i = 1; i <= n; ++i)
    {
        int x;
        cin >> x;
        ++cnt[x];
    }

    p[cnt[1]][cnt[2]][cnt[3]] = 1;
    ev[cnt[1]][cnt[2]][cnt[3]] = 0;

    for(int k3 = n; k3 >= 0; --k3)
        for(int k2 = n; k2 >= 0; --k2)
            for(int k1 = n; k1 >= 0; --k1)
                if(p[k1][k2][k3] > 0)
                    if(k1 + k2 + k3 > 0)
                    {
                        long double p0 = (long double) (n - k1 - k2 - k3) / n;

                        ev[k1][k2][k3] += (1 + cost(p0)) * p[k1][k2][k3];

                        if(k1)
                        {
                            long double curP = (long double) k1 / (k1 + k2 + k3);
                            p[k1 - 1][k2][k3] += curP * p[k1][k2][k3];
                            ev[k1 - 1][k2][k3] += curP * ev[k1][k2][k3];
                        }
                        if(k2)
                        {
                            long double curP = (long double) k2 / (k1 + k2 + k3);
                            p[k1 + 1][k2 - 1][k3] += curP * p[k1][k2][k3];
                            ev[k1 + 1][k2 - 1][k3] += curP * ev[k1][k2][k3];
                        }
                        if(k3)
                        {
                            long double curP = (long double) k3 / (k1 + k2 + k3);
                            p[k1][k2 + 1][k3 - 1] += curP * (p[k1][k2][k3]);
                            ev[k1][k2 + 1][k3 - 1] += curP * (ev[k1][k2][k3]);
                        }
                    }

    cout << setprecision(10) << fixed << ev[0][0][0] << '\n';

    return 0;
}



Measured memory_bytes: 864512
#include <iostream>
using namespace std;
int main() {
	int N, K, Q, A;
	cin >> N >> K >> Q;
	int right[100000] {};
	for (int i = 0; i < Q; i++) {
		cin >> A;
		right[A - 1]++;
	}
	for (int i = 0; i < N; i++) cout << (K - Q + right[i] > 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define PII pair<long long, long long>
#define F first
#define S second


using namespace std;

typedef long long ll;

ll n, k, mn = 9e18;
PII x[55];

int main()
{
    scanf("%lld%lld", &n, &k);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld", &x[i].F, &x[i].S);
    }
    sort(x, x + n);
    for(ll i = 0; i < n - k + 1; i++)
    {
        vector<ll> ve;
        ve.clear();
        for(ll j = i; j < i + k - 1; j++)
        {
            ve.push_back(x[j].S);
        }
        for(ll j = i + k - 1; j < n; j++)
        {
            ll wid = x[j].F - x[i].F;
            ve.push_back(x[j].S);
            sort(ve.begin(), ve.end());
            for(ll ii = 0; ii < ve.size() - k + 1; ii++)
            {
                ll hig = ve[ii + k - 1] - ve[ii];
                mn = min(mn, wid * hig);
            }
        }
    }
    printf("%lld", mn);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

typedef struct Node {
    int k;
    int p;
    struct Node *left;
    struct Node *right;
} Node;

Node *getNewNode(int k, int p){
    static int i = 0;
    static Node node[200000];
    node[i].k = k;
    node[i].p = p;
    node[i].left = nullptr;
    node[i].right = nullptr;
    return &node[i++];
}

Node *rightRotate(Node *t){
    Node *s = t->left;
    t->left = s->right;
    s->right = t;
    return s;
}

Node *leftRotate(Node *t){
    Node *s = t->right;
    t->right = s->left;
    s->left = t;
    return s;
}

Node *insert(Node *t, int k, int p){
    if(t == nullptr){
        return getNewNode(k, p);
    } else if(k < t->k){
        t->left = insert(t->left, k, p);
        if(t->p < t->left->p){
            t = rightRotate(t);
        }
    } else if(k > t->k){
        t->right = insert(t->right, k, p);
        if(t->p < t->right->p){
            t = leftRotate(t);
        }
    }
    return t;
}
Node *delete_(Node *t, int k);
Node *_delete(Node *t, int k){
    if(t->left == nullptr && t->right == nullptr){
        return nullptr;
    } else if(t->left == nullptr){
        t = leftRotate(t);
    } else if(t->right == nullptr){
	t = rightRotate(t);
    } else {
        if(t->left->p > t->right->p){
            t = rightRotate(t);
        } else {
            t = leftRotate(t);
        }
    }
    return delete_(t, k);
}

Node *delete_(Node *t, int k){
    if(t == nullptr){
        return nullptr;
    }
    if(k < t->k){
        t->left = delete_(t->left, k);
    } else if(k > t->k){
        t->right = delete_(t->right, k);
    } else {
        return _delete(t, k);
    }
    return t;
}
Node *find(Node *t, int k){
    if(t == nullptr){
        return nullptr;
    }
    if(k < t->k) return find(t->left, k);
    else if(k > t->k) return find(t->right, k);
    else return t;
}

void print_inorder(Node *t){
    if(t == nullptr) return;
    print_inorder(t->left);
    std::printf(" %d", t->k);
    print_inorder(t->right);
}

void print_preorder(Node *t){
    if(t == nullptr) return;
    std::printf(" %d", t->k);
    print_preorder(t->left);
    print_preorder(t->right);
}

int main(){
    int n;
    std::scanf("%d", &n);
    Node *root = nullptr;

    for(int i = 0; i < n; ++i){
	char op[8];
	std::scanf("%s", op);
	if(std::strncmp(op, "insert", 6) == 0){
            int k;
            std::scanf("%d", &k);
            int p;
            std::scanf("%d", &p);
            root = insert(root, k, p);
	} else if(std::strncmp(op, "delete", 6) == 0){
            int k;
            std::scanf("%d", &k);
            root = delete_(root, k);
	} else if(std::strncmp(op, "find", 4) == 0){
            int k;
            std::scanf("%d", &k);
            if(find(root, k) != nullptr){
		std::printf("yes\n");
            } else {
		std::printf("no\n");
            }
	} else if(std::strncmp(op, "print", 5) == 0){
            print_inorder(root);
            std::printf("\n");
            print_preorder(root);
            std::printf("\n");
	}
    }

    return 0;
}



Measured memory_bytes: 7444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
int K,S;
int main(){
  cin>>K>>S;
  int res=0;
  rep(x,K+1){
    rep(y,K+1){
      int z=S-(x+y);
      if(0<=z&&z<=K) res++;
    }
  }
  prin(res);
  return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 2e5 + 10;
int a[MAXN];
int pre[MAXN];

void solve(){
    int n,k; cin>>n>>k;

    for(int i=1;i<=n;i++) cin>>a[i];

    for(int i=1;i<=n;i++) pre[i] = pre[i-1] + a[i];

    for(int i=1;i<=n;i++) pre[i] -= i,pre[i] = (pre[i] + k)%k;

    int ans = 0;

    map<int,int> frq;

    for(int i=0;i<=n;i++){
        if(i >= k){
            frq[pre[i-k]]--;
        }
        ans += frq[pre[i]];
        frq[pre[i]]++;
    }

    cout<<ans<<endl;
}

signed main(){


    int t;
    t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 15872
//==================================================================================================
// Name        : hs_dxd.cpp
// Author      : lotus.eater086
// Copyright   : If you're reading this then this warning is for you. Every word you read of this 
//               useless fine print is another second of your life. Don't you've other things to do?
//               Is your life so empty that you honestly can't think of a better way to spend these
//               moments ? Or are you so impressed with authority that you give respect and 
//               credence to all who claim it ? Do you read everything you're supposed to read ? Do
//               you think everything you're supposed to think ? Buy what you're told you should 
//               want ? Get out of your apartment . Meet a member of the opposite sex. Stop the 
//               excessive shopping and self-improvement . Quit your boring job.
//               Start a fight. Prove you're alive. If you don't claim your humanity you'll become a
//               statistic. You've been warned !

// Description : 
// Date        : 2019-10-04
// Time        : 21:02:57
// Directory   : C:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode
// FilePath    : C:\Users\Lenovo\cpPractise\deliberatePractise\code_folder\.vscode\hs_dxd.cpp
//==================================================================================================
    

#include <bits/stdc++.h>
#define LL long long
#define endl "\n"

using namespace std ;
    
//
template < typename T >

inline T read( T &x )
{

    x = 0 ;

    int f = 0 ;

    char ch = getchar() ;

    while( ch < '0' || ch > '9' )  {

        f |= ( ch == '-' ) , ch = getchar() ;

    }

    while( ch >= '0' && ch <= '9' )  {

        x = ( x << 1 ) + ( x << 3 ) + ch - '0' , ch = getchar() ;

    }

    return x = f ? -x:x ;

}
//

int cnt = 0 ;

void selection_sort( vector<int> &v )
{

    for( int i = 0 ; i < v.size() ; i++ )  {

        int mini = i ;

        for( int j = i ; j < v.size() ; j++ )  {

            if( v[j] < v[mini] )  {

                mini = j ;

            }

        }

        swap(v[i],v[mini]) ;

        if( i != mini )  cnt++ ;  

    }

}

void print_vector( vector<int> v )
{

    cout << v[0] ;  

    for( int i = 1 ; i < v.size() ; i++ )  {

        cout << " " << v[i] ;

    }

    cout << endl ; 

}

void solve( void )
{

    int n ;

    cin >> n ;

    vector<int> v(n) ;

    for( int i = 0 ; i < n ; i++ )  {

        cin >> v[i] ;  

    }

    selection_sort( v ) ;

    print_vector(v) ;

    cout << cnt << endl ; 

}

int main( void )

{

    //ios_base::sync_with_stdio( false ) ;  cin.tie( NULL ) ;  cout.tie( NULL ) ;


    if( 0 )  {

        int t = 100 ;

        for( int i = 1 ; i <= t ; i++ )  solve() ;

    }

    else  {

        solve() ;

    }

   

    return 0 ;

}



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

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

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

    ll ans = 0;

    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int m = 1; m <= k; m++){
                ll o = gcd(i, j);
                ans += gcd(o, m);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <climits>
#include <vector>
#include <algorithm>
using namespace std;

void lazy_query(int k, vector<int>& node, vector<int>& lazy, int n) {
	if (lazy[k] == INT_MAX)return;
	node[k] = lazy[k];
	if (k < n - 1) {
		lazy[2 * k + 1] = lazy[k];
		lazy[2 * k + 2] = lazy[k];
	}
	lazy[k] = INT_MAX;
}

void update(int a, int b, int x, int k, int l, int r, vector<int>&node, vector<int>& lazy, int n) {
	lazy_query(k, node, lazy, n);
	if (r <= a || b <= l)return;
	if (a <= l && r <= b) {
		lazy[k] = x;
		lazy_query(k, node, lazy, n);
		return;
	}
	else {
		update(a, b, x, 2 * k + 1, l, (l + r) / 2, node, lazy, n);
		update(a, b, x, 2 * k + 2, (l + r) / 2, r, node, lazy, n);
		node[k] = min(node[2 * k + 1], node[2 * k + 2]);
		return;
	}
}

int find(int a, int b, int k, int l, int r, vector<int>&node, vector<int>& lazy, int n) {
	lazy_query(k, node, lazy, n);
	if (r <= a || b <= l)return INT_MAX;
	if (a <= l && r <= b) {
		return node[k];
	}
	else {
		lazy_query(k, node, lazy, n);
		int vl = find(a, b, 2 * k + 1, l, (l + r) / 2, node, lazy, n);
		int vr = find(a, b, 2 * k + 2, (l + r) / 2, r, node, lazy, n);
		return min(vr, vl);
	}
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n_, q;  cin >> n_ >> q;
	int n = 1;
	while (n < n_) n *= 2;
	vector<int> node(2 * n - 1, INT_MAX);
	vector<int> lazy(2 * n - 1, INT_MAX);

	for (int i = 0; i < q; i++) {
		int com; cin >> com;
		if (com == 0) {
			int s, t, x; cin >> s >> t >> x;
			update(s, t + 1, x, 0, 0, n, node, lazy, n);
		}
		else {
			int s, t; cin >> s >> t;
			cout << find(s, t + 1, 0, 0, n, node, lazy, n) << endl;
		}
	}
}

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

using namespace std;
vector<long long> v(5,0);
int main()
{
    int n;

    cin >> n;

    while (n--)
    {
        string s;
        cin>>s;

        if(s[0] == 'M')
            v[0]++;
        if(s[0] == 'A')
            v[1]++;
        if(s[0] == 'R')
            v[2]++;
        if(s[0] == 'C')
            v[3]++;
        if(s[0] == 'H')
            v[4]++;
    }

    long long total = 0;

    for (int i = 0; i < 5; i++)
    {
        for (int j = i + 1; j < 5; j++)
        {
            for (int k = j + 1; k < 5; k++)
            {
                total += v[i] * v[j] * v[k];
            }
        }
    }

    cout << total << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; i++)
#define RFOR(i, a, n) for (ll i = (ll)n - 1; i >= (ll)a; i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define bra(first, second) '(' << first << ',' << second << ')'
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;
ll INF = 1001001001001001001;
long double EPS = 1e-9;
long double PI = 3.141592653589793238;
template <typename T>
void remove(std::vector<T> &vector, unsigned int index)
{
   vector.erase(vector.begin() + index);
}

using Graph = vector<vector<tuple<ll, ll, ll>>>;

// MOD確認

ll x[5];

int main(){
   ll X,Y;
   cin >> X >> Y;
   rep(i,X+1){
      if(2*i + (X-i) * 4 == Y){
         cout << "Yes" << endl;
         return 0;
      }
   }
   cout << "No" << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
#define MOD 1000000007
typedef long long ll;

using namespace std;

int main() 
{
  int tarou = 0, hanako = 0;
  int num;
  cin >> num;
  REP(i, num) {
    string t, h;
    cin >> t >> h;
    if (t > h) {
      tarou += 3;
    } else if (t < h) {
      hanako += 3;
    } else if (t == h) {
      tarou++;
      hanako++;
    }
  }

  cout << tarou << " " << hanako << "\n";
}



Measured memory_bytes: 3200
import java.util.*;

class Main{
	public static void main(String args[]) throws Exception{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a > b){
			System.out.println(a - 1);
		}else{
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 21716
import collections
s = input()
t = input()

cs = collections.Counter(s)
ct = collections.Counter(t)

sv = []
tv = []
for v in cs.values():
    sv.append(v)
for v in ct.values():
    tv.append(v)
    
sv.sort()
tv.sort()
if len(sv) == len(tv):
    for i in range(len(sv)):
        if sv[i] != tv[i]:
            print('No')
            exit()
    else:
        print('Yes')
else:
    print('No')

Measured memory_bytes: 4144
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt();
        int k = sc.nextInt();
        int s = 1 , cou = 0;
        long q = 1;
        while(s == 1){
            q = q * k;
            cou++;
            if(n < q){
                s = cou;
                s = 0;
            }
        }
        System.out.println(cou);
        sc.close();
    }
}

Measured memory_bytes: 35648
#include<stdio.h>
#include<stdlib.h>
#define INF 100000000

int table[100][100];
int d[100], q_emp = 0, pop_cnt = 0;
int Q[100];

void push(int s){
  Q[q_emp + pop_cnt] = s;
  q_emp++;
}

int pop(){
  int s;
  s = Q[pop_cnt];
  pop_cnt++;
  q_emp--;
  return s;
}

void BFS(int s, int n){
  int i, u, v;
  push(s);
  for(i = 0; i < n; i++) d[i] = INF;
  d[s] = 0;
  while(q_emp != 0){
    u = pop();
    for(v = 0; v < n; v++){
      if(table[u][v] == 0) continue;
      if(d[v] != INF) continue;
      d[v] = d[u] + 1;
      push(v);
    }
  }
  for(i = 0; i < n; i++){
    if(d[i] != INF)
      printf("%d %d\n", i+1, d[i]);
    else
      printf("%d %d\n", i+1, -1);
  }
}


  
  
int main(){
  int i, j, n, u, k, v;
  
  scanf("%d", &n);
  if(n >= 1 && n <= 100){
    for(i = 0; i < n; i++){
      for(j = 0; j < n; j++) table[i][j] = 0;
    }
    
    for(i = 0; i < n; i++){
      scanf("%d %d", &u, &k);
      u--;
      for(j = 0; j < k; j++){
	scanf("%d", &v);
	v--;
	table[u][v] = 1;
      }
    }
    
    BFS(0, n);
  }
  return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

int main(){

int n,m;
  
  cin >> n >> m;
  
  int a[m];
 
  for(int i=0;i<m;i++){
   cin >> a[i];
  }
  
  long dp[n+1]={0};
   dp[0]=1;
  long k=0;
  
  if(a[k]==1){
   dp[1]=0;
    k++;
  }
  else{
   dp[1]=1;
  }
  
  
  for(int i=2;i<=n;i++){
   
     dp[i]=dp[i-1]+dp[i-2];
    dp[i]%=1000000007;
    
    if(i==a[k]){
     dp[a[k++]]=0;  
    }
  }
   
  
  
  cout << dp[n] << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <set>

void solve() {
    int n;
    std::cin >> n;

    std::set<std::string> ss;
    while (n--) {
        std::string s;
        std::cin >> s;
        ss.insert(s);
    }

    std::cout << ss.size() << std::endl;
}

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

    solve();

    return 0;
}


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

int main(){
  int c[4][4];
  for(int i=1; i<=3; i++){
    for(int j=1; j<=3; j++) cin >> c[i][j];
  }

  if((c[1][1]-c[1][2]==c[2][1]-c[2][2])&&(c[2][1]-c[2][2]==c[3][1]-c[3][2]) && ((c[1][2]-c[1][3]==c[2][2]-c[2][3])&&(c[2][2]-c[2][3]==c[3][2]-c[3][3]))){
    cout << "Yes" << endl;
  }else cout << "No" << endl;
  return 0;
}


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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int m=0, temp=0;
    for (char c: s){
        if (c=='I'){
            temp++;
            m=max(m, temp);
        } else {
            temp--;
        }
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#define ll long long
#define mod 1000000007
//priority_queue 优先队列 
typedef unsigned long long ull;
const int INF=0x3f3f3f3f;
const int N=2e5+5;
using namespace std;
const int b=13331;//质数 

int n,m;
int dp[N]={0}; 
ll t,sum=0;
priority_queue <ll> s;
int main(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
    	cin>>t;
    	s.push(t);
	}
	while(m&&!s.empty()){
		ll a=s.top();
		m--;
		s.pop();
		s.push(a/2);
	}
	while(!s.empty()){
		ll a=s.top();
		sum+=a;
		s.pop();
	}
	cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll a[105][105]={{}};
  ll b[105][105]={{}};
  int n,m,l;
  int i,j,k;
  cin >> n >> m >> l;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  for(i=0;i<m;i++){
    for(j=0;j<l;j++){
      cin >> b[i][j];
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<l;j++){
      ll o=0;
      for(k=0;k<m;k++){
	o+=a[i][k]*b[k][j];
      }
      if(j==0) cout << o;
      else cout << " " << o; 
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3268
def toi(a)
	b = []
	a.each do |n|
		b << n.to_i
	end
	b	
end

a = toi(gets.split)
if 0<=a[2]-a[4]&&a[2]+a[4]<=a[0]&&0<=a[3]-a[4]&&a[3]+a[4]<=a[1]
	puts("Yes")
else
	puts("No")
end

Measured memory_bytes: 8684
N = int(input())
A = list(map(int, input().split()))

ans = 0

up = None

for i in range(1, N):
    if up == None:
        if not A[i] == A[i - 1]:
            up = A[i] > A[i - 1]
            
    elif up:
        if A[i] < A[i - 1]:
            ans += 1
            up = None

    else:
        if A[i] > A[i - 1]:
            ans += 1
            up = None

print(ans + 1)

Measured memory_bytes: 19948
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto ds = readln.split.to!(int[]);
    sort(ds);
    auto M = readln.chomp.to!int;
    auto ts = readln.split.to!(int[]);
    sort(ts);
    size_t i, j;
    while (i < N && j < M) {
        if (ds[i] < ts[j]) {
            ++i;
        } else if (ds[i] == ts[j]) {
            ++i;
            ++j;
        } else {
            writeln("NO");
            return;
        }
    }
    writeln(j == M ? "YES" : "NO");
}

Measured memory_bytes: 17680
N, M = map(int, input().split())
to1 = [[0] for i in range(N)]
ab = [[0, 0] for i in range(M)]

for i in range(M):
    ab[i][0], ab[i][1] = map(int, input().split())
    to1[ab[i][0]-1].append(ab[i][1]-1)
    to1[ab[i][1]-1].append(ab[i][0]-1)

ans = 0

def DFS(n):
    global v
    if v[n] == 1:
        return
    v[n] = 1
    for i in to1[n]:
        DFS(i)

for i in range(M):
    v = [0] * N
    p = ab[i]
    p[0] -= 1
    p[1] -= 1
    to1[p[0]].remove(p[1])
    to1[p[1]].remove(p[0])
    DFS(0)
    if sum(v) != N:
        ans += 1
    to1[p[0]].append(p[1])
    to1[p[1]].append(p[0])

print(ans)

Measured memory_bytes: 9232
#include <stdio.h>

int main(void)
{
	int a,b,c,i;
	int count=0;

	scanf("%d%d%d", &a,&b,&c);
	for(i=a; i<=b; i++){
		if(c%i == 0)
			count++;
	}
	printf("%d\n", count);
	return 0;

}

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


int main(){
    string s;
    getline(cin, s);
    string w;
    int c = 0;
    for(string::iterator it = s.begin(); it != s.end(); it++){
        if( *it == ' ' || *it == ',' || *it == '.' ){
            if( w.size() >= 3 && w.size() <= 6 ){
                if( c ) cout << ' ';
                cout << w;
                c = 1;
            }
            w = string("");
        }else{
            w.append(it, it+1);
        }
    }
    if( w.size() >= 2 && w.size() <= 7 ){
        if( c ) cout << ' ';
        cout << w;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

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

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int X;
  cin >> X;

  int x = 0;
  for (int i = 1; i <= X; i++) {
    x += i;
    if (x >= X) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
int main(){
    int n,m;cin>>n>>m;
    vector<string>A,B;
    string s;bool flag=true;
    fol(i,n){cin>>s;A.pb(s);}
    fol(i,m){cin>>s;B.pb(s);}
    fol(i,n-m)fol(j,n-m){
            flag =true;
            fol(k,m)fol(l,m)if(A[i+k][j+l]!=B[k][l])flag=false;
            if (flag){cout << "Yes"<<endl;return 0;}
        }
    if(flag) cout << "Yes"<<endl;
    else cout << "No"<<endl;
    return 0;
}


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


void solve(long long K, long long N, std::vector<long long> A){
    auto b = vector<long long>(N, 0);
    for (int i = 1; i < N; i++) {
        b[i] = A[i] - A[i-1];
    }
    b[0] = K + A[0] - A[N-1];
    long long c = accumulate(b.begin(), b.end(), 0);
    auto d = max_element(b.begin(), b.end());
    cout << (c - *d) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
  int i,c=-1,f=-1;
  string s;
  cin >> s;
  for (i=0;i<s.size();i++){
    if (s[i]=='C' && c==-1) c=i;
    if (s[i]=='F') f=i;
  }
  if (c!=-1 && f!=-1 && c<f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
string str;
cin >> str;
string result;
for (int i = 0; i < str.size(); ++i) {
   if (str[i] == 'B') {
     if (!result.empty()) {
     result.pop_back();
   }}
  else {
     result.push_back(str[i]);

}

}
cout << result <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int n,x,y;
  cin >> n >> x >> y;
  
  vector<int> res(n-1);
  for(int i = 0;i <= n - 2;i++)res[i] = 0;
  for(int i = 0;i <= n - 2;i++){
    for(int j = i + 1;j <= n - 1;j++){
      int kyori = 0;
      kyori = min({abs(j - i),1 + abs(x - 1 - i) + abs(j - y + 1),1 + abs(y - 1 - i) + abs(j - x + 1)});
      res[kyori - 1]++;
      //cout << "i" << i << " j" << j << " " << kyori << endl;
    }
  }
  for(int i = 0;i <= n - 2;i++){
    cout << res[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN=2e5;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int c=0;
    for(int i=0;i<n;i++)
    {
        if(s.substr(i,3)=="ABC")
            c++;
    }
    cout << c;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	cout << (double)((n+1)/2)/n << endl;
}

Measured memory_bytes: 256
import java.io.*;

class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int m = 0;
        int f = 0;
        int r = 0;        
        
        while(true) {
            String str[] = br.readLine().split(" ");
            m = Integer.parseInt(str[0]);
            f = Integer.parseInt(str[1]);
            r = Integer.parseInt(str[2]);

            if (m == -1 && f == -1 && r == -1) {
                break;
            }
            if (m == -1 || f == -1)
                System.out.println("F");
            else if (m + f >= 80)
                System.out.println("A");
            else if (m + f >= 65)
                System.out.println("B");
            else if (m + f >= 50)
                System.out.println("C");
            else if (m + f >= 30) {
                if (r >= 50)
                    System.out.println("C");
                else
                    System.out.println("D");
            } else
                System.out.println("F");
        }
    }
}

Measured memory_bytes: 24108
// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
const int NINF = -1*INF;
const long long LLINF = 1ll << 60;
const long long LLNINF = -1*LLINF;

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
	return os << "[ " << p.first << ", " << p.second << "]" ;
}

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<pi> vpi;
typedef vector<vector<int>> vvi;
typedef vector<vll> vvll;
typedef vector<vd> vvd;
typedef vector<vld> vvld;
 
#define mp make_pair
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define revAll(x) x.rbegin(), x.rend()
#define gcd(a, b) __gcd(a, b)
#define popcount(x) __builtin_popcount(x)
#define isize(x) (int)(x.size())
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define umap unordered_map

const ll MOD = 1e9 + 7;

struct SegTree{
	int n;
	vvi T;

	SegTree(vi& B){
		n = isize(B);
		T = vvi(4*n + 10);
		build(B, 1, 0, n-1);
	}

	void build(vi& B, int v, int tl, int tr){
		if (tl == tr){
			T[v] = {B[tl]};
		}else{
			int mid = (tl + tr)/2;
			build(B, 2*v, tl, mid);
			build(B, 2*v+1, mid+1, tr);
			vi new_v = vi();
			fcmerge(T[2*v], T[2*v+1], new_v);
			// merge(all(T[2*v]), all(T[2*v+1]), back_inserter(new_v));
			T[v] = new_v;
		}
	}

	void fcmerge(vi& A, vi& B, vi& res){
		int i = 0, j = 0, m = isize(A), n = isize(B);
		while (i < m and j < n){
			if (A[i] <= B[j]){
				res.pb(A[i]);
				i++;
			}else{
				res.pb(B[j]);
				j++;
			}			
		}
		if(i == m){
			while(j < n){
				res.pb(B[j]);
				j++;
			}
		}else{
			while(i < m){
				res.pb(A[i]);
				i++;
			}
		}
	}

	int qry(int l, int r, int x, int v, int tl, int tr){
		if (l > tr or r < tl) return 0;
		if (l <= tl and tr <= r){
			auto pt = lower_bound(all(T[v]), x+1);
			return distance(pt, T[v].end());
		}
		int mid = (tl + tr)/2;
		int L = qry(l, r, x, 2*v, tl, mid);
		int R = qry(l, r, x, 2*v+1, mid+1, tr);
		return L + R;
	}

};

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	int n, q; cin >> n >> q;
	vi A = vi();
	rep(i, n){
		int x; cin >> x;
		A.pb(x);
	}
	vi B = vi(n);
	umap<int, int> last = umap<int, int>();
	for(int i = isize(A)-1; i >= 0; i--){
		int val = A[i];
		if (last.find(val) == last.end()){
			B[i] = INF;
		}else{
			B[i] = last[val];
		}
		last[val] = i; 
	}
	SegTree ST = SegTree(B);
	rep(i, q){
		int l, r; cin >> l >> r;
		l--, r--;
		int ans = ST.qry(l, r, r, 1, 0, isize(B)-1);
		cout << ans << "\n";
	}
}

Measured memory_bytes: 140144
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    static final int MODULUS = 1_000_000_007;

    static Map<Long, Integer> cache = new HashMap<>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();

        System.out.println(solve(N));

        sc.close();
    }

    // http://oeis.org/A007729
    static int solve(long N) {
        if (N <= 1) {
            return (int) N + 1;
        }

        if (cache.containsKey(N)) {
            return cache.get(N);
        }

        int result;
        if (N % 2 == 0) {
            result = addMod(multiplyMod(solve(N / 2 - 1), 2), solve(N / 2));
        } else {
            result = addMod(multiplyMod(solve(N / 2), 2), solve(N / 2 - 1));
        }
        cache.put(N, result);

        return result;
    }

    static int addMod(int x, int y) {
        return (x + y) % MODULUS;
    }

    static int multiplyMod(int x, int y) {
        return (int) ((long) x * y % MODULUS);
    }
}

Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int n, uf_par[112345], uf_rnk[112345];

void uf_init(int size)
{
    REP(i, size)
    {
        uf_par[i] = i;
        uf_rnk[i] = 0;
    }
}

int uf_find(int x)
{
    if (uf_par[x] == x)
        return x;
    else
        return uf_par[x] = uf_find(uf_par[x]);
}

void uf_unite(int x, int y)
{
    x = uf_find(x);
    y = uf_find(y);
    if (x == y)
        return;

    if (uf_rnk[x] < uf_rnk[y])
    {
        uf_par[x] = y;
    }
    else
    {
        uf_par[y] = x;
        if (uf_rnk[x] == uf_rnk[y])
            uf_rnk[x]++;
    }
}

bool uf_same(int x, int y)
{
    return uf_find(x) == uf_find(y);
}

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

    int m;
    cin >> n >> m;

    int a[112345];
    REP(i, m + 1)
    a[i] = -1;

    uf_init(n);

    REP(i, n)
    {
        int k, l[112345];
        cin >> k;
        REP(j, k)
        {
            cin >> l[j];
            if (a[l[j]] != -1)
            {
                uf_unite(i, a[l[j]]);
            }
            else
            {
                a[l[j]] = i;
            }
        }
    }

    bool res = true;

    REP(i, n - 1)
    if (!uf_same(i, i + 1))
        res = false;

    cout << (res ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int H; int N; cin>>H>>N;
  vector<int> S(N);
  for(int i=0; i<N; i++){
    cin>>S.at(i);
    H-=S.at(i);
  }
  if(H<=0)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef unsigned long long ull;

typedef pair < db, db > pdd;
typedef pair < db, ld > pdl;
typedef pair < ld, db > pld;
typedef pair < ld, ld > ldp;

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

#define F first
#define S second

#define en end()
#define bg begin()

#define rev reverse
#define mp make_pair
#define pb push_back

#define y1 y1234567890
#define um unordered_map

#define all(x) x.bg, x.en
#define sz(x) (int)x.size()
#define len(x) (int)strlen(x)

#define sqr(x) ((x + 0ll) * (x))
#define sqrd(x) ((x + 0.0) * (x))

#define forn(i, n) for (int i = 1; i <= n; i++)

const ll inf = (ll)1e18;
const ll mod = (ll)1e9 + 7;

const db eps = (db)1e-9;
const db pi = acos(-1.0);

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

const int N = 200500;

int n, x, u[N];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	//freopen(".err", "w", stderr);

	//srand(time(NULL));

	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	//cout << setprecision(10) << fixed;
	
	cin >> n >> x;

	if (x == 1 || x == n + n - 1) {
		cout << "No";
		return 0;
	}

	cout << "Yes" << endl;

	if (n == 2) {
		cout << "1\n2\n3\n";
		return 0;
	}

	if (x == 2)
		u[x] = u[x - 1] = u[x + 1] = u[x + 2] = 2;
	else
		u[x] = u[x - 1] = u[x + 1] = u[x - 2] = 2;

	for (int i = 1, ptr = 1; i < n - 1; i++) {
		while (u[ptr]) ptr++;
		u[ptr] = 1;
		cout << ptr << endl;
	}

	if (x == 2)
		cout << x + 2 << endl << x << endl << x - 1 << endl << x + 1 << endl;
	else
		cout << x - 2 << endl << x << endl << x + 1 << endl << x - 1 << endl;

	for (int i = 1, ptr = 1; i < n - 2; i++) {
		while (u[ptr]) ptr++;
		u[ptr] = 1;
		cout << ptr << endl;
	}
	
	//cerr << (clock() + 0.0) / CLOCKS_PER_SEC;

	return 0;
}


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

int main () {
  int h, w;	cin >> h >> w;
  string s[100];
  rep(i,h) cin >> s[i];
  rep(i,h)rep(j,w){
    if (s[i][j] == '#') continue;
    s[i][j] = '0';
    
    for(int dx = -1; dx<=1; dx++) {
      for(int dy= -1; dy<=1; dy++) {
        int nx=i+dx, ny=j+dy;
        if(nx >= 0 && nx < h && ny >= 0 && ny < w) {
          if(s[nx][ny] == '#')	s[i][j]++;
        }
      }
    }
  }
  rep(i,h)	cout << s[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll X;
	cin >> X;
	for (ll a = -1000; a <= 1000; a++) {
		for (ll b = -1000; b <= 1000; b++) {
			if (a * a * a * a * a - b * b * b * b * b == X) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

int main(){
  int N;
  cin >> N;
  string ans = "No";
  rep(i,10){
    if(0 == i) continue;
    if(0 == N%i){
      int a = N/i;
      if(10 > a){
        ans = "Yes";
        break;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = RDA;

	long ans = 1;
	long[] s = [0, 0, 0];
	foreach (i; 0..N)
	{
		long cnt;
		foreach (j; 0..3)
		{
			if (s[j] == A[i]) 
				++cnt;
		}
		foreach (j; 0..3)
		{
			if (s[j] == A[i]) 
			{
				++s[j];
				break;
			}
		}
		ans.modm(cnt);
	}
	
	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;

int main(){
    ll n;
    cin>>n;
    cout<<1-n;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   string s,t,u;
   cin >> s >> t >> u;  
   cout << s[0] << t[1] << u[2] << endl;
}

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

#define MAX_D 10
#define MAX_P 100

int main() {
    int D, G;
    cin >> D >> G;
    int p[MAX_D+1], c[MAX_D+1];
    for (int i = 0; i < D; i++) {
        cin >> p[i] >> c[i];
    }
    int mincount = 10000;
    // まず、ボーナスを含めて、ある問題セットすべてを解いたときを仮定(ビット探索、0も含む)
    // そして、足りない分は、大きい点数の方から追加していく
    for (int b = 0; b < (1 << D); b++) {
        int count = 0;
        int sumval = 0;
        // 全部解く問題
        for (int i = 0; i < D; i++) {
            if (b & (1 << i)) {
                sumval += (i+1) * 100 * p[i] + c[i];
                count += p[i];
            }
        }
        // 全部解いたの以外で足していく
        for (int i = D-1; i >= 0; i--) {
            if (!(b & (1 << i))) {
                for (int j = 0; j < p[i]-1; j++) {
                    if (sumval >= G) break;
                    sumval += (i+1) * 100;
                    count++;
                }
            }
        }
        if (sumval >= G) mincount = min(count, mincount);
    }
    cout << mincount << endl;
    return 0;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
   int n,a,b;
   cin>>n>>a>>b;
   cout<<min(n*a,b)<<endl;
   return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, d;
	cin >> n >> d;

	ll res = 0;
	while (n--) {
		ll x, y;
		cin >> x >> y;
		res += x*x + y*y <= d*d;
	}
	cout << res << endl;

}



Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

using namespace std;
typedef long long ll;
typedef long double ld;

void bug();

/* BIEN CUC BO BEGIN*/
	int n;
	
	ld ans = 0.0;
	ld rate = 380000.0;
/* BIEN CUC BO END*/

void solve(){	
	cin >> n;
	for(int i=1; i<=n; ++i){
		ld x;
		string s;
		cin >> x >> s;
		if (s == "BTC"){
			x *= rate;
		}
		ans += x; 
	}
	cout << fixed << setprecision(5) << ans;
}	

int main(){ FIO;
	solve();
return 0;}


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

int main()
{
	int N; cin >> N;
	vector<long long>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];

	long long l = 0, r = 2e9 + 1;

	while (l < r)
	{
		long long m = (l + r) / 2;

		long long x = m;
		for (int i = 1; i < N; i++)
		{
			x = A[i] - x;
		}
		x = A[0] - x;

		if(x < m)r = m;
		else l = m+1;
	}

	vector<long long>ans(N);
	int x = r-1;
	for (int i = 0; i < N; i++)
	{
		ans[(i+1)%N] = 2*x;
		
		x = A[(i + 1) % N] - x;
	}
	for (int i = 0; i < N; i++)
	{	
		if(i)cout<<" ";
		cout<<ans[i];
	}
	cout<<endl;

	return 0;
}

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

#define FO(i,a,b) for (int i = (a); i < (b); i++)
#define sz(v) int(v.size())

using namespace std;

typedef long long ll;

ll f(ll a, ll b) {
    if (a < b) swap(a,b);
    if (a % b == 0) {
        return 2 * a - b;
    }
    ll t = a / b;
    return t * 2 * b + f(a - t*b, b);
}

int main() {
    ll n, x;
    scanf("%lld %lld", &n, &x);
    printf("%lld\n", n + f(n-x, x));
}



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

int main(){
    int A,B;
    cin >> A >> B;
    if (A == 1 && B == 2) cout << 3 << endl;
    else if (A == 1 && B == 3) cout << 2 << endl;
    else if (A == 2 && B == 1) cout << 3 << endl;
    else if (A == 2 && B == 3) cout << 1 << endl;
    else if (A == 3 && B == 1) cout << 2 << endl;
    else cout << 1 << endl;
}


Measured memory_bytes: 256