akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(void)
{
   int n,i;
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
        int base=0,score=0,outcount=0;
        while(1)
        {
            int res1,res2;
            char event[10],*hit="HIT",*homerun="HOMERUN";
            scanf("%s",event);
            res1=strcmp(hit,event);
            res2=strcmp(homerun,event);
            if(res1==0)
            {
                if(base<3)
                {
                    base++;
                }
                else
                {
                    score++;
                }
            }
            else if(res2==0)
            {
                score+=base+1;
                base=0;
            }
            else
            {
               outcount++;
               if(outcount==3)
               {
                   printf("%d\n",score);
                   break;
               }
            }
        }
   }
    return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int h,w;
    cin >> h >> w;
    vector<string> table;
    table.push_back(string(w+2,'.'));
    rep(i,h){
        string s;
        cin >> s;
        table.push_back("." + s + ".");
    }
    table.push_back(string(w+2,'.'));

    for(int i = 1;i<=h;i++){
        for(int j = 1;j<=w;j++){
            int ans = 0;
            if(table[i][j] == '#'){
                cout << '#';
                continue;
            }
            //上下左右
            if(table[i-1][j] == '#')ans++;
            if(table[i+1][j] == '#')ans++;
            if(table[i][j-1] == '#')ans++;
            if(table[i][j+1] == '#')ans++;
            if(table[i-1][j-1] == '#')ans++;
            if(table[i+1][j+1] == '#')ans++;
            if(table[i+1][j-1] == '#')ans++;
            if(table[i-1][j+1] == '#')ans++;
            cout << ans;
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n,l,r;
  cin >> n >> l >> r;
  if(n==25){ cout << "Christmas" << endl; return 0;}
  if(n==24){ cout << "Christmas Eve" << endl; return 0;}
  if(n==23){ cout << "Christmas Eve Eve" << endl; return 0;}
  if(n==22){ cout << "Christmas Eve Eve Eve" << endl; return 0;}
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
#define SIZE 105
double dp[SIZE][SIZE];
int n,m;
double level[SIZE][SIZE];
int main()
{
	while(1)
	{
		scanf("%d %d",&n,&m);
		if(n==0&&m==0)break;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				scanf("%lf",&level[i][j]);
			}
		}
		memset(dp,0,sizeof(dp));
		for(int i=0;i<n;i++)dp[1][i]=1.0;
		for(int i=1;i<m;i++)
		{
			for(int j=0;j<n;j++)
			{
				for(int k=0;k<n;k++)
				{
					dp[i+1][k]=max(dp[i+1][k],dp[i][j]*level[j][k]);
				}
			}
		}
		double ans=0.0;
		for(int i=0;i<n;i++)ans=max(ans,dp[m][i]);
		printf("%.2f\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1424
let n = read_int ()
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let s, l = ref 0, ref 0
let _ = Array.(sort (-) a_s; iteri (fun i a -> if i > 0 then s := !s + a_s.(i - 1); if a > 2 * !s then l := i) a_s); Printf.printf "%d\n" @@ n - !l

Measured memory_bytes: 5376
#!/mnt/c/Users/moiki/bash/env/bin/python
# FROM : https://atcoder.jp/contests/abc111/submissions/4032175

N = int(input())
targets = [ list(map(int, input().split())) for _ in range(N)]

mod_1st = sum(targets[0]) % 2 
if not all( sum(t) %2 == mod_1st for t in targets[1:]):
    print(-1)
    exit(0)

mod = mod_1st
print(33 - mod)  # 33 or 32 
D = [2**i for i in range(31, -1, -1)] # 32
if mod == 0:
    D.append(1)
print(' '.join(map(str, D)))
# ----
for (x,y) in targets:
    temp = []
    u = x+y
    v = x-y
    for d in D:
        if u >= 0:
            if v >= 0:
                temp.append("R")
                u -= d
                v -= d
            elif v <  0:
                temp.append("U")
                u -= d
                v += d
        elif u < 0:
            if v >= 0:
                temp.append("D")
                u += d
                v -= d
            elif v < 0 :
                temp.append("L")
                u += d
                v += d

    print(''.join(temp))


Measured memory_bytes: 43120
#include <bits/stdc++.h>
#ifdef DEBUG
  #include "debug.hpp"
#else
  #define DUMP(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
using value_type = typename iterator_traits<FwdIter>::value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int /*argc*/, char ** /*argv*/) {
  ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

  size_t n;
  cin >> n;
  vector<size_t> a(1ULL << n);
  cin >> a;
  map<size_t, size_t, greater<size_t>> cnt;
  for (const auto i: a) {
    ++cnt[i];
  }
  map<size_t, size_t> xs;
  {
    auto i = cnt.begin(); // std::prev(cnt.end());
    xs.emplace(i->first, 1);
    if (--(i->second) == 0) {
      cnt.erase(i);
    }
  }

  for (size_t k = 0; k < n; ++k) {
    vector<size_t> buf;
    for (auto iter = xs.crbegin(); iter != xs.crend(); ++iter) {
      const auto pr = *iter;
      auto i = cnt.upper_bound(pr.first);
      for (size_t j = 0; j < pr.second; ++j) {
        if (i == cnt.end()) {
          cout << "No";
          return 0;
        }
        buf.push_back(i->first);
        if (--(i->second) == 0) {
          i = cnt.erase(i);
        }
      }
    }
    for (const auto i: buf) {
      ++xs[i];
    }
  }
  cout << "Yes";

  return EXIT_SUCCESS;
}


Measured memory_bytes: 20340
strN = input()
N = int(strN)
K = int(input())
ans = 0
lenN = len(strN)
if K == 1:
    while(1):
        if N >= 10:
            ans += 9
            N //= 10
        else:
            ans += N
            break
elif K == 2:
    if lenN >= 2:
        index = 1
        while (index < lenN):
            if int(strN[index]) != 0:
                ans += 9 * (lenN - 1 - index)
                ans += int(strN[index])
                break
            index += 1
        ans += (int(strN[0]) - 1) * 9*(lenN-1)

        ans += 9 * 9 * (((lenN - 1) * (lenN - 2)) // 2)


elif K == 3:
    if lenN >= 3:
        index = 1
        index_2 = 0
        while (index < lenN and index_2 == 0):
            if int(strN[index]) != 0:
                ans += (int(strN[index]) - 1) * 9 * (lenN - 1 - index)
                ans += 9*9*(((lenN - 1-index) * (lenN - 2-index)) // 2)
                index_2 += index+1
                while (index_2 < lenN):
                    if int(strN[index_2]) != 0:
                        ans += int(strN[index_2])
                        ans += 9*(lenN-1-index_2)
                        break
                    index_2 += 1
            index += 1
        #ans += 9 * 9 * (((lenN - 2) * (lenN - 3)) // 2)
        ans += (int(strN[0]) - 1) * 9 * 9 * (((lenN - 1) * (lenN - 2)) // 2)
        ans += 9*9*9*(((lenN-1)*(lenN-2)*(lenN-3))//6)
        # for h in range(1, lenN - 2):
        #    ans += 9 * 9 * 9*(((lenN-1-h)*(lenN-2-h))//2)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
    
    
    typedef pair<long long , long long> pair_t;

    int main(){
        long long n , a , b;
        long long ans = 0;
        cin >> n ;
        vector<pair_t> v;
        for(long i = 0 ; i < n ; i++){
            cin >> a >> b;
            pair_t pt;
            pt = make_pair(a , b);
            v.push_back(pt);
        }
        long long temp;
        for(long i = v.size() - 1 ; i >= 0 ; i--){
            pair_t pt = v[i];
            temp = pt.first + ans;
            if(temp % pt.second == 0 ){
                
            }else{
                ans += pt.second - (temp % pt.second) ;
            }
        }
        
        cout << ans << endl;
        
        
        return 0;
        
    }

Measured memory_bytes: 2420
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  long a[100000],b[100000],ans=0,temp,ans2=0,c[100000],sum=0,sum2,p;
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
    scanf("%ld",&a[i]);
  sort(a,a+n);
  for(int i=0;i<n;i++){
    if(i<n/2)
      sum+=2*a[i];
    else
      sum-=2*a[i];
  }
  if(n%2==0){
    ans=sum-a[0];
    for(int i=0;i<n/2;i++)
      if(labs(ans)<labs(sum-a[i]))
        ans=sum-a[i];
    sum2=ans;
  }
  else{
    ans=sum+a[n/2];
    p=n/2;
    for(int i=n/2;i<n;i++)
      if(labs(ans)<labs(sum+a[i])){
        ans=sum+a[i];
        p=i;
      }
    sum2=ans;
  }
  if(n%2==0||p!=n/2)
    ans+=a[n/2];
  else
    ans+=a[n/2+1];
  for(int i=n/2;i<n;i++)
    if(labs(ans)<labs(sum2+a[i])&&(n%2==0||p!=n/2))
      ans=sum2+a[i];
  sum=0;
  if(n%2==1){
    for(int i=0;i<n;i++){
      if(i<=n/2)
        sum+=2*a[i];
      else
        sum-=2*a[i];
    }
    ans2=sum-a[0];
    p=0;
    for(int i=0;i<=n/2;i++)
      if(labs(ans2)<labs(sum-a[i])){
        ans2=sum-a[i];
        p=i;
      }
    sum2=ans2;
    if(p!=0)
      ans2-=a[0];
    else
      ans2-=a[1];
    for(int i=0;i<=n/2;i++)
      if(labs(ans)<labs(sum2-a[i])&&p!=i)
        ans2=sum2-a[i];
    ans=max(labs(ans),labs(ans2));
  }
  printf("%ld\n",labs(ans));
}

Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] tmpArray = br.readLine().split(" ");
		int n = Integer.parseInt(tmpArray[0]);
		int q = Integer.parseInt(tmpArray[1]);

		ArrayManager array = new ArrayManager(n);

		for(int i = 0; i < q; i++){
			tmpArray = br.readLine().split(" ");

			int x = Integer.parseInt(tmpArray[1]);
			int y = Integer.parseInt(tmpArray[2]);

			if(tmpArray[0].equals("0")){
				array.update(x, y);
			}
			else {
				int result = array.findMin(x, y);
				System.out.println(result);
			}
		}
	}

}

class ArrayManager {
	private int[] array;
	private int n;
	private final int INIT = Integer.MAX_VALUE;

	public ArrayManager(int n){
		this.n = n;
		array = new int[n];

		Arrays.fill(array, INIT);
	}

	public void update(int index, int num){
		array[index] = num;
	}

	public int findMin(int s, int t){
		int min = Integer.MAX_VALUE;

		for(int i = s ; i <= t; i++){
			if(min > array[i]){
				min = array[i];
			}
		}

		return min;
	}
}

Measured memory_bytes: 64184
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,m,ans=0,i,x,y;
		vector<pii> v;
		cin>>n>>m;
		rep(i,0,n)
		{
			cin>>x>>y;
			v.pb({x,y});
		}
		sort(all(v));
		i=0;
		while(m>0)
		{
			if(v[i].second>=m)
			{
				ans+=v[i].first*m;
				m=0;
			
			}
			else
			{
				ans+=v[i].first*v[i].second;
				m-=v[i].second;
			}
			i++;
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 2420
N,M,K = map(int, input().split())
MOD = 998244353

fact = [1]
rfact = [1]
for i in range(1, N+1):
    fact.append(fact[i-1]*i%MOD)
    rfact.append(pow(fact[i], MOD-2, MOD))
 
def cmb(n, m):
    return fact[n]*rfact[m]*rfact[n-m]%MOD

answer = 0
for i in range(K+1):
    answer += (M*cmb(N-1,i)*pow(M-1,N-1-i,MOD))%MOD
print(answer%MOD)

Measured memory_bytes: 98620
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
ans = 0
a_dict = {}
for i,x in enumerate(a,1):
    a_dict[i] = x
for k,v in a_dict.items():
    if k in [a_dict[v]]:
        ans +=1
print(ans//2)


Measured memory_bytes: 31644
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static final int ID_MAX = 1000;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while(true){
			final int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			String prev_day = "";
			boolean[] is_in = new boolean[ID_MAX];
			int[] in_time = new int[ID_MAX];
			int[] bless_time = new int[ID_MAX];
			
			for(int q = 0; q < n; q++){
				final String day = sc.next();
				
				if(!prev_day.equals(day)){
					prev_day = day;
					
					Arrays.fill(is_in, false);
					Arrays.fill(in_time, Integer.MAX_VALUE);
				}
				
				String time_str[] = sc.next().split(":");
				final int time = Integer.parseInt(time_str[0]) * 60 + Integer.parseInt(time_str[1]);
				
				boolean in = sc.next().equals("I");
				
				final int id = sc.nextInt();
				
				if(id == 0){
					if(in){
						is_in[id] = true;
						
						for(int i = 0; i < ID_MAX; i++){
							if(is_in[i]){
								in_time[i] = time;
							}
						}
					}else{
						is_in[id] = false;
						
						for(int i = 0; i < ID_MAX; i++){
							if(is_in[i]){
								 bless_time[i] += time - in_time[i];
							}
						}
					}
				}else{
					if(in){
						is_in[id] = true;
						in_time[id] = time; 
					}else{
						if(is_in[0]){
							bless_time[id] += time - in_time[id];
						}
						is_in[id] = false;
						in_time[id] = Integer.MAX_VALUE;
					}
				}
			}
			
			int max_time = 0;
			for(int i = 0; i < ID_MAX; i++){
				max_time = Math.max(max_time, bless_time[i]);
			}
			System.out.println(max_time);
			
		}
		
	}

}

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

int main()
{
	int n,k; cin>>n ;
	int ar[n][3];
	for(int i=0;i<n;i++) cin>>ar[i][0]>>ar[i][1]>>ar[i][2];
	for(int i=1;i<n;i++){
		ar[i][0]+=max(ar[i-1][1],ar[i-1][2]);
		ar[i][1]+=max(ar[i-1][0],ar[i-1][2]);
		ar[i][2]+=max(ar[i-1][1],ar[i-1][0]);
	}
	cout<<max(ar[n-1][0],max(ar[n-1][1],ar[n-1][2]))<<endl;
} 


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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n, 0);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        cnt.at(a - 1)++;
        cnt.at(b - 1)++;
    }
    for (int i = 0; i < n; i++)
    {
        cout << cnt.at(i) << endl;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
#define EPS 1e-6
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64; 
long long const INF = 1e18 + 42;
 
 
int main(){
	fast;
	string s;
	cin>>s;
	int n= s.size();
	bool flag=1;
	for(int i=0; i<n; i++){
	    if(s[i]!=s[n-i-1]) flag=0;
	    if(i<(n-1)/2 && s[i]!=s[(n-1)/2-i-1]) flag=0;
	    if(i>=((n+3)/2-1) && s[i]!= s[n-i-1]) flag=0;
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define FOR(x,val,to) for(int x=(val);x<int((to));++x)
#define FORE(x,val,to) for(auto x=(val);x<=(to);++x)
#define FORR(x,arr) for(auto &x: arr)
#define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x)
#define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x)
#define REE(s_) {cout<<s_<<'\n';exit(0);}
#define GET(arr) for(auto &i: (arr)) sc(i)
#define whatis(x) cerr << #x << " is " << x << endl;
#define e1 first
#define e2 second
#define INF 0x7f7f7f7f
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::vector<std::string> vs;
typedef int64_t ll;
typedef uint64_t ull;
#define umap unordered_map
#define uset unordered_set
using namespace std;
using namespace __gnu_pbds;

#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; }
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; }
inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;}
inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}}
inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}}
template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); }
template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound
template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 1000000007

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll a,b,c,k;
    sc(a,b,c,k);
    if(k&1) swap(a,b);
    cout << a-b << '\n';
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	vpii H(N, pair<int, bool>(0, true));
	for (int i = 0; i < N; i++)
		cin >> H[i].first;

	for (int i = 0; i < M; i++)
	{
		int A, B;
		cin >> A >> B;
		A--; B--;
		if (H[A].first <= H[B].first)
			H[A].second = false;
		if (H[A].first >= H[B].first)
			H[B].second = false;
	}

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (H[i].second)
			ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 4052
#![allow(non_snake_case)]
#![allow(unused_imports)]
use ascii::AsciiChar;
use ascii::AsciiStr;
use itertools::Itertools as _;
use permutohedron::LexicalPermutation as _;
use petgraph::algo::dijkstra;
use petgraph::algo::min_spanning_tree;
use petgraph::data::FromElements;
use petgraph::graph::NodeIndex;
use petgraph::graph::UnGraph;
use petgraph::unionfind::UnionFind;
use proconio::fastout;
use proconio::input;
use proconio::marker::Chars;
use proconio::marker::Usize1;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use superslice::Ext as _;

#[fastout]
fn main() {
    input! {
        H: usize,
        W: usize,
        mut Fieldss: [Chars; H],
    }

    // ルートを全探索するなら、(H+W-2)C(H-1)
    // H <= 13とかならいけるけど、100だとムリ
    // O(HWW)かO(HHW)かな

    // 途中から問題を勘違いしてしまって全く別の問題を実装完了してしまったので、
    // 答えを見て改めて実装。

    let mut dp = vec![vec![0; W]; H];
    dp[0][0] = if Fieldss[0][0] == '#' { 1 } else { 0 };

    for w in 1..W {
        if Fieldss[0][w - 1] == '.' && Fieldss[0][w] == '#' {
            dp[0][w] = dp[0][w - 1] + 1;
        } else {
            dp[0][w] = dp[0][w - 1];
        }
    }

    for h in 1..H {
        if Fieldss[h - 1][0] == '.' && Fieldss[h][0] == '#' {
            dp[h][0] = dp[h - 1][0] + 1;
        } else {
            dp[h][0] = dp[h - 1][0];
        }
    }

    for h in 1..H {
        for w in 1..W {
            // →
            let right_cand = if Fieldss[h][w - 1] == '.' && Fieldss[h][w] == '#' {
                dp[h][w - 1] + 1
            } else {
                dp[h][w - 1]
            };

            // ↓
            let down_cand = if Fieldss[h - 1][w] == '.' && Fieldss[h][w] == '#' {
                dp[h - 1][w] + 1
            } else {
                dp[h - 1][w]
            };

            dp[h][w] = min(right_cand, down_cand);
        }
    }

    // debug
    // for h in 0..H {
    //     for w in 0..W {
    //         eprint!("{} ", dp[h][w]);
    //     }
    //     eprintln!("");
    // }

    let ans = dp[H - 1][W - 1];
    println!("{}", ans);
    // println!("1234");
}


Measured memory_bytes: 2268
#pragma GCC optimize("O3") 

#include <bits/stdc++.h>
using namespace std;

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

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

#define test(t)		        int t; cin >> t; while(t--)
#define f(i, a, b)	        for(int (i) = (a); (i) < (b); ++(i))
#define all(a)		        (a).begin(), (a).end()
#define endl 		        "\n"
#define maxvec(vec)             *max_element(all(vec))
#define minvec(vec)             *min_element(all(vec))
#define maxarr(arr)             *max_element(arr, arr + n)
#define minarr(arr)             *min_element(arr, arr + n)
#define deb(x)		        cout << #x << ": " << x << endl;
#define deb2(x,y)	        cout << #x << ": " << x << " ~ " <<  #y << ": " << y << endl;
#define deba(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n << " "; cout << "]" << endl;
#define debap(arr)	        cout << #arr << " ~ [ "; for(auto n: arr) cout << n.first << "-" << n.second << " "; cout << "]" << endl;
#define fast 		        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

#define mx9		1000000007
#define mx7		10000007
#define mx6		1000006
#define mx5		200005
#define inf		1<<30                                 
#define eps		1e-9
#define mod		1000000007
#define PI		3.141592653589793238462643383279502884L

void solve()
{
    string s;
    cin >> s;
    ll n = s.length(), sum = 0;
    f(i, 0, n)
    {
        sum += (s[i] - '0');
        sum %= 9;
    }
    if(sum % 9)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

int main()
{
    fast;
    // test(t)
        solve();
    return 0;
}

Measured memory_bytes: 3764
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        int n = scanInt();
        int ac = 0, wa = 0, tle = 0, re = 0;


        for (int i = 0; i < n; i++) {
            switch(scanString()) {
            case "AC":
                ac++;
                break;
            case "WA":
                wa++;
                break;
            case "TLE":
                tle++;
                break;
            case "RE":
                re++;
                break;
            }
        }
        out.println("AC x " + ac);
        out.println("WA x " + wa);
        out.println("TLE x " + tle);
        out.println("RE x " + re);
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 47792
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		char[] s = in.next().toCharArray();		
		int cnt = 0;
		String prev = "";
		String now = "";
		for ( int i = 0; i < s.length; i++ ) {
			now += s[i];
			if( !prev.equals(now)) {
				cnt++;
				prev = now;
				now = "";
			}			
		}
		System.out.println(cnt);
		in.close();
	}
}

Measured memory_bytes: 44560
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
	int n;
	double x1,x2,x3,y1,y2,y3,px,py,r,a,b,c,d,e,f;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		a = (x2-x1)*2.0;
        b = (y2-y1)*2.0;
        c = (x2*x2 + y2*y2 - x1*x1 - y1*y1);
        d = (x3-x1)*2.0;
        e = (y3-y1)*2.0;
        f = (x3*x3 + y3*y3 - x1*x1 - y1*y1);
        px = (c*e-b*f)/(a*e-b*d);
        py = (a*f-c*d)/(a*e-b*d);
        r = sqrt((px-x1)*(px-x1) + (py-y1)*(py-y1));
        printf("%.3f %.3f %.3f\n",px,py,r);
	}
}


Measured memory_bytes: 1244
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	a, z := -1, -1
	s := readString()
	for i := 0; i < len(s); i++ {
		if string(s[i]) == "A" {
			a = i
			break
		}
	}
	for i := len(s) - 1; i >= 0; i-- {
		if string(s[i]) == "Z" {
			z = i
			break
		}
	}
	fmt.Println(z - a + 1)
}


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

using namespace std;
#define li long long int

int solve(vector <int> v,int n,int i,int j,vector <vector<int >> dp)
{
    //Base
    if(i>j)
    {
        return 0;
    }
    if(i==j)
    {
        return v[i];
    }
    if(i==j-1)
    {
        return max(v[i],v[j]);
    }

    if(dp[i][j]!=-1e9)
    {
        return dp[i][j];
    }


    return dp[i][j]=max(v[i]+min(solve(v,n,i+1,j-1,dp),solve(v,n,i+2,j,dp)),v[j]+min(solve(v,n,i,j-2,dp),solve(v,n,i+1,j-1,dp)));

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int n,i,x;
    cin>>n;

    li dp[n+1]={0},h[n+1]={0};
    
    
    for(i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    
    
    dp[0]=dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
   
    for(i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n];
    
    return 0;
}


Measured memory_bytes: 1792
<?php
while ($input = trim(fgets(STDIN))) {
	list($a, $b, $c, $d, $e, $f) = explode(" ", $input);
	$x = ($b*$f-$c*$e) / ($b*$d-$a*$e);
	$y = ($a*$f-$c*$d) / ($a*$e-$b*$d);
	echo number_format($x, 3)." ".number_format($y, 3)."\n";
}

Measured memory_bytes: 15232
#include<iostream>
#include<string>
#include<map>
int main()
{
	std::string w;
	std::cin>>w;
	std::map<std::string, int> count;
	for (unsigned int i = 0; i < w.size(); i++)
	{
		auto itr = count.find(std::to_string(w[i]));
		if (itr != count.end())
		{
			count[std::to_string(w[i])] += 1;
		}
		else
		{
			count[std::to_string(w[i])] = 1;
		}
	}
	std::string result = "Yes";
	for (auto index = count.begin(); index != count.end(); index++)
	{
		int buf = index->second;
		if (buf % 2 == 1)
		{
			result = "No";
			break;
		}
	}
	std::cout << result << "\n";
    return 0;
}



Measured memory_bytes: 256
/// meowa 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define low lower_bound
#define upp upper_bound
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse((a).begin(), (a).end());
#define sz(x) (int) x.size()
 
using namespace std;

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

const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
  
//ll
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void stndrtn() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

void ma1n() {
    ll x, k, d;
    cin >> x >> k >> d;  
    x = abs(x);
    ll ans = 0;
    if (k < x/d) {
        ans = x-k*d;
    } else {
        k -= x/d;     
        x -= x/d*d;   
        if (k & 1) {  
            ans = d-x;
        } else {      
            ans = x;  
        }             
    }
    cout << ans;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Measured memory_bytes: 3644
N = int(input())
a = list(int(i) for i in input().split())

Alice = 0
Bob = 0

if N%2 == 0:
    for n in range(int(N/2)):
        Alice += max(a)
        a.remove(max(a))
        Bob += max(a)
        a.remove(max(a))
else:
    for n in range(int((N-1)/2)):
        Alice += max(a)
        a.remove(max(a))
        Bob += max(a)
        a.remove(max(a))
    Alice += max(a)
print(Alice - Bob)

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

int cc(int x,int y){
  return x*(100+y)/100;
}

int cul(int x,int y,int z){
  return cc(x,z)+cc(y,z);
}

int solve(int x,int y,int z){
  int ans = 0;
  for(int i=1;i<1000;i++){
    for(int j=1;j<1000;j++){
      if(cc(i,x)+cc(j,x)==z){
        ans = max(ans,cul(i,j,y));
      }
    }
  }
  return ans;
}

int main(){
  int x,y,z;
  while(cin>>x>>y>>z,!(x==0&&y==0&&z==0)){
    cout<<solve(x,y,z)<<endl;
  }
}

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

int calcDigit(long long);
int calcMaxDigit(long long, long long);

int main(void){
    long long N;
    cin >> N;
    long long a=1;
    long long b;
    int digit;
    int min_digit=INT32_MAX;
    for(; a<=sqrt(N); a++){
        if(N%a != 0){
            continue;
        }
        b = N/a;
        digit = calcMaxDigit(a, b);
        if(digit < min_digit){
            min_digit = digit;
        }
    }
    cout << min_digit;
    return 0;
}

int calcDigit(long long a){
    int i=1;
    while(1){
        if(a < pow(10, i)){
            return i;
        }
        i++;
    }
}

int calcMaxDigit(long long a, long long b){
    int a_digit = calcDigit(a);
    int b_digit = calcDigit(b);
    if(a_digit < b_digit){
        return b_digit;
    }else{
        return a_digit;
    }
}

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

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

  int keta[4] = {};
  for(int i=3; i>=0; i--){
    keta[i] = int(n/pow(10,i));
    n -= keta[i]*pow(10,i);
  }

  if(keta[1]!=keta[2]){
    cout << "No" << endl;
  }else if(keta[0]==keta[1] || keta[3]==keta[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

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

using namespace std;

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

	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	a.emplace_back(0);

	int num = 0;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == i + 1) {
			num = 1;
			i++;
			while (a[i] == i + 1) {
				num++;
				i++;
			}
			ans += (num + 1) / 2;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
     
    int main(void)
    {
        int N;
     
        scanf("%d", &N);
     
        if (1<=N && N<= 999)
        {
            printf("ABC");
        }
        else if (1000<= N && N<=1998)
        {
            printf("ABD");
        }
        return 0;
    }

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 999999
char str[SZ];
int ts[SZ],tn=0,su=0;
void jw(bool f=1)
{
	for(int i=1;i<=tn&&(f||ts[i]>=10);++i)
	{
		su-=ts[i]; su-=ts[i+1];
		ts[i+1]+=ts[i]/10,ts[i]%=10;
		su+=ts[i]; su+=ts[i+1];
	}
	int&i=tn;
	while(ts[i+1])
	{
		su-=ts[i]; su-=ts[i+1];
		++i,ts[i+1]+=ts[i]/10,ts[i]%=10;
		su+=ts[i]; su+=ts[i+1];
	}
}
int main()
{
	scanf("%s",str);
	for(int i=strlen(str)-1;i>=0;--i)
		ts[++tn]=str[i]-48;
	for(int i=1;i<=tn;++i) ts[i]*=9;
	jw();
	su=0;
	for(int i=1;i<=tn;++i) su+=ts[i];
	for(int k=0;;++k)
	{
		if(k) ts[1]+=9,su+=9; jw(0);
		if(su<=9*k)
		{
			printf("%d\n",k);
			return 0;
		}
	}
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  string s;cin>>s;
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      ans++;
    }
  }
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        
        int N=sc.nextInt();
        int Y=sc.nextInt();
        
        int rest,num,numgo,numiti;
        boolean undone=true;
        for(int i=0;i<=Y/10000;i++){
            rest=Y-10000*i;
            num=N-i;
            numgo=(rest-1000*num)/4000;
            numiti=num-numgo;
            if(rest-1000*num>=0&&numiti>=0&&5000*numgo+1000*numiti==rest){
                System.out.println(
                    String.valueOf(i)+" "+
                    String.valueOf(numgo)+" "+
                    String.valueOf(numiti)
                );
                undone=false;
                break;
            }
        }
        if(undone){
            System.out.println("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 23764
def d_built(N, P):
    class UnionFind(object):
        def __init__(self, n):
            self.p = list(range(n))  # i番の頂点の親(parent)はi番とする
            self.rank = [0] * n  # 全頂点はランク0(繋がりなし)とする
            self.size = [1] * n  # 全頂点の連結成分の大きさ1とする

        def union(self, x, y):  # x,yを同じ連結成分に属させる
            u = self.find(x)
            v = self.find(y)
            if u == v:  # x,yは既に同じ連結成分に属していた
                return
            if self.rank[u] < self.rank[v]:
                self.p[u] = v  # ランクの大きな方につなげる
                self.size[v] += self.size[u]  # つながっている要素数だけ足す
                self.size[u] = 0  # ランクが小さかった連結成分は「解散」
            else:
                # 上と同様にやる
                self.p[v] = u
                self.size[u] += self.size[v]
                self.size[v] = 0
                if self.rank[u] == self.rank[v]:
                    # 根の分だけ1個「ずれる」
                    self.rank[u] += 1
            # 経路圧縮を行い、連結成分の代表を更新
            self.find(x)
            self.find(y)
            return None

        def find(self, x):  # 頂点xが属する連結成分の代表(根の番号)を求める
            if self.p[x] != x:  # 頂点xの代表は他の頂点だった
                self.p[x] = self.find(self.p[x])  # 経路圧縮(xを代表につなぐ)
            return self.p[x]

        def is_same(self, x, y):  # 頂点x,yは同じ連結成分に属するか？
            return self.find(x) == self.find(y)

    xs, ys = [], []
    for i, (x, y) in enumerate(P):
        xs.append((x, i))
        ys.append((y, i))
    xs.sort()
    ys.sort()

    # 頂点をつなぐ辺の候補を得る
    x_edge, y_edge = [], []
    for i in range(N - 1):
        # x座標、y座標でソートしたもので隣り合った2点を結ぶ
        x_edge.append((xs[i][1], xs[i + 1][1], xs[i + 1][0] - xs[i][0]))
        y_edge.append((ys[i][1], ys[i + 1][1], ys[i + 1][0] - ys[i][0]))
    x_edge.extend(y_edge)  # 頂点a-b間を結ぶ辺のコスト
    x_edge.sort(key=lambda x: x[2])  # コストの小さいものから並べる(クラスカル法のため)

    # クラスカル法による
    uf = UnionFind(N)
    edges = []  # 辺の情報を格納
    for x1, x2, cost in x_edge:
        if not uf.is_same(x1, x2):
            # x1, x2が同じ木に属していた場合、注目した辺を加えると閉路ができる
            uf.union(x1, x2)
            edges.append(cost)
        if len(edges) == N - 1:
            break
    return sum(edges)

N = int(input())
P = [[int(i) for i in input().split()] for j in range(N)]
print(d_built(N, P))

Measured memory_bytes: 68044
#include "bits/stdc++.h"
using namespace std;
#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(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a<=c && c<=b) 
        cout << "Yes"<< endl;
    else
        cout << "No"<< endl;

    return 0;
}

Measured memory_bytes: 256
a = input()
l = a.split()
h = int(l[0])
n = int(l[1])
b = input()
ll = b.split()
for i in range(0,n):
    ll[i] = int(ll[i])

sum = sum(ll)
if h<sum+1:
    print("Yes")
else:
    print("No")    


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

int place(char num){
  int x=num-'0';
  if(x%3==0){
    return 2;
  }
  if(x%3==1) return 0;
  return 1;
}
int main(){
  string cmd;
  while(cin>>cmd,cmd!="#"){
    if(cmd.size()==1){
      cout<<0<<endl;
      continue;
    }
    const int INF=1e6;
    vector<vector<int>> dp(cmd.size(),vector<int>(2,INF));
    for(int j=0;j<2;j++) dp[0][j]=0;
    string s=cmd;
    for(int i=1;i<cmd.size();i++){
      //dp[i][0]:lef pivot
      if(place(s[i-1])<=place(s[i])){
	dp[i][0]=dp[i-1][1];
	dp[i][1]=dp[i-1][1]+1;
      }

      if(place(s[i-1])>=place(s[i])){
	dp[i][1]=min(dp[i-1][0],dp[i][1]);
	dp[i][0]=min(dp[i][0],dp[i-1][0]+1);
      }

    }
    cout<<min(dp[cmd.size()-1][0],dp[cmd.size()-1][1])<<endl;
  }
  return 0;

}

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

#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(v,a,b) for(int v=(a); v<=(b); v++)
#define fr(v,a,b) for(int v=(a); v>=(b); v--)
#define rng(v,a,b) for(int v=(a); v<(b); v++)

using namespace std;
typedef long long ll;
template<typename T> T& chmax(T& a, T b) { a = a > b ? a : b; return a;}
template<typename T> T& chmin(T& a, T b) { a = a < b ? a : b; return a;}
//const int maxn;
int main()
{
	int r; cin >> r;
	cout << 3*r*r << '\n';
	return 0;
}


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

int main(){
    int H, W, N;
    cin >> H >> W >> N;

    if(H < W){
        for(int i = 0; i < H; i++){
            if(W * (i+1) >= N){
                cout << i+1 << endl;
                break;
            }
        }
    }else{
        for(int i = 0; i < W; i++){
            if(H * (i+1) >= N){
                cout << i+1 << endl;
                break;
            }
        }
    }

    return 0;
}

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

int main(){
  int n;cin>>n;
  int ans[n];
  for(int i=0;i<n;i++){int a;cin>>a;ans[a-1]=i;}
  for(int i=0;i<n;i++){cout <<ans[i]+1<<" ";}
  cout <<endl;
}

Measured memory_bytes: 1152
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);

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

	string S;
	cin >> S;
	int score = 0, gu = 0, pa = 0;
	rep(i, S.size()) {
		if (S[i] == 'g') {
			if (pa < gu) {
				pa++;
				score++;
			}
			else {
				gu++;
			}
		}
		else {
			if (pa < gu) {
				pa++;
			}
			else {
				gu++;
				score--;
			}
		}
	}
	cout << score << endl;

	return 0;
}

Measured memory_bytes: 512
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	N, _ := strconv.Atoi(scanner.Text())

	words := []string{}
	for i := 0; i < N; i++ {
		scanner.Scan()
		words = append(words, scanner.Text())
	}

	for x, y := range words {
		if x != N-1 {
			if !strings.HasSuffix(y, words[x+1][0:1]) {
				fmt.Println("No")
				os.Exit(0)
			}
		}
		for _, v := range words[x+1:] {
			if y == v {
				fmt.Println("No")
				os.Exit(0)
			}
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 640
def main():
    n = int(input())
    h = list(map(int, input().split()))
    h = [0] + h
    count = 0
    for i in range(len(h) - 1):
        tmp = h[i + 1] - h[i]
        count += tmp * int(tmp > 0)
    print(count)

if __name__ == '__main__':
    main()


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

int main(){
  long n, k;  cin >> n >> k;
  vector<long> a(n+1, 0);
  for(int i=1; i<=n; i++)  cin >> a[i];

  for(int i=k+1; i<=n; i++){
    string ans = "No";
    if(a[i] > a[i-k])  ans = "Yes";
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 4844
from collections import Counter
#from itertools import combinations
n = int(input())
lst = ["".join(sorted(list(input()))) for i in range(n)]
#lst2 = 1#Counter(lst)
#for i in len(lst):
#  print(i.values)


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

#print(cmb(4,2),0,0,0)
cnt = 0
for i in Counter(lst).values():
  if i == 1:
    continue
  cnt += cmb(i, 2)
"""
for i in range(len(lst)-1):
  for j in range(i+1,len(lst)):
    #print(0)
    if lst[i]==lst[j]:
      cnt += 1
"""
print(cnt)

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    cout << (A+B >= C ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//Input
		Scanner sc = new Scanner(System.in);
		int R = Integer.parseInt(sc.next());
		int G = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int N = Integer.parseInt(sc.next());
		sc.close();

		//Logic
		int answer = 0;
		for (int r = 0 ; r <= N ; r++) {
			{
				for (int g = 0 ; g <= N ; g++) {
						if(((N - r * R - g * G) / B >= 0) && ((N - r * R - g * G) % B == 0)) {
							answer++;
						}
				}
			}
		}

		//Output
		System.out.println(answer);
	}
}


Measured memory_bytes: 21844