akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{

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

		int cnt=0;
		for(int i=0;i<3;i++) {
			int num=scan.nextInt();
			cnt+=num;
		}
		scan.close();

		if(cnt>=22) System.out.println("bust");
		else  System.out.println("win");

	}

}

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

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A

int main() {
	int n;
	cin >> n;
	int arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	
	cout << arr[0];
	for (int j = 1; j < n; j++) cout << " " << arr[j];
	cout << endl;
	
	for (int i = 1; i < n; i++) {
		int current = arr[i];
		if (arr[i - 1] > current) {
			int j = i;
			do {
				arr[j] = arr[j - 1];
				j--;
			} while (j > 0 && arr[j - 1] > current);
			arr[j] = current;
		}
		cout << arr[0];
		for (int j = 1; j < n; j++) cout << " " << arr[j];
		cout << endl;
	}
	return 0;
}

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

typedef long long ll;


int main() {
    int N;
    cin >> N;
    int mx;
    for(int i=1;;i++){
        if ((1+i)*i/2 >= N){
            mx = i;
            break;
        }
    }
    int skip = (1+mx)*mx/2 - N;
    for (int i=1;i<=mx;i++){
        if (i==skip) continue;
        cout << i << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define double long double
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define mp  make_pair
#define all(v) (v).begin(), (v).end()
#define mod 1000000007  
#define mod2 998244353  
#define pi 3.14159265358979323846 

int solve(){
    int n,a,b,x;
    cin>>n>>a>>b;a--;b--;
    int d[n-1]={0};
    rep(i,0,n){
        x=0;
        rep(j,i+1,n){
            int y=abs(i-a)+abs(j-b);
            if(y<x) d[y]++;
            else d[x]++;
            x++;
        }
    }
    rep(i,0,n-1) cout<<d[i]<<"\n";
    return 0;
}   
     
signed main(){
    IOS;
    //freopen("input.txt", "r" , stdin);
    //freopen("output4.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<"\n";
      // cout<<" * "<<t<<"\n";
    }
//    return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        int N = sc.nextInt();
        int M = sc.nextInt();
 
        int A[][] = new int[N][M];
        int B[] = new int[M];
 
        for(int row = 0; row < N; row++){
            for(int col = 0; col < M; col++){
                A[row][col] = sc.nextInt();
            }
        }
 
        for(int row = 0; row < M; row++){
            B[row] = sc.nextInt();
        }
 
        int ans;
 
        for(int row = 0; row < N; row++){
            ans = 0;
            for(int col = 0; col < M; col++){
                ans += A[row][col]*B[col];
            }
            System.out.printf("%d\n", ans);
        }
    }
}


Measured memory_bytes: 40512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#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 all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int K,X;
int main(){
	cin >> K >> X;
	for(int i=max(-1000000,X-K+1);i<=min(1000000,X+K-1);i++){
		cout << i;
		if(i==min(1000000,X+K-1))cout << endl;
		else cout << ' ';
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
function Main(input) {
  const args = input.split("\n");
  const num = args[0];
  const half = num / 2;
  const str = args[1];
  var ret = false;
  var countR = 0;
  var countB = 0;

  for(var ch of str) {
    if (ch === 'R') {
      countR++;
      if (countR > half) {
        ret = true;
        break;
      }
    } else {
      countB++;
      if (countB >= half) {
        ret = false;
        break;
      }
    }
  }

  console.log(ret ? 'Yes' : 'No');
}


Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 22204
#include<stdio.h>
int main(){
	int a,b,c;
	int 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int dp[MAX][10][10][2];

vector<int> dx={0,1,2,3,1,0,3,1,2,3};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        string S;cin>>S;
        if(S=="#") break;
        int N=S.size();
        
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                for(int i=0;i<=N;i++){
                    dp[i][j][k][0]=INF;
                    dp[i][j][k][1]=INF;
                }
                dp[0][j][k][0]=0;
                dp[0][j][k][1]=0;
            }
        }
        
        for(int i=0;i<N;i++){
            for(int j=0;j<10;j++){
                for(int k=0;k<10;k++){
                    int to=S[i]-'0';
                    if(dx[to]<=dx[k]){
                        dp[i+1][to][k][0]=min(dp[i+1][to][k][0],dp[i][j][k][0]+1);
                        dp[i+1][to][k][0]=min(dp[i+1][to][k][0],dp[i][j][k][1]);
                    }
                    
                    if(dx[j]<=dx[to]){
                        dp[i+1][j][to][1]=min(dp[i+1][j][to][1],dp[i][j][k][0]);
                        dp[i+1][j][to][1]=min(dp[i+1][j][to][1],dp[i][j][k][1]+1);
                    }
                }
            }
        }
        
        int ans=INF;
        
        for(int j=0;j<10;j++){
            for(int k=0;k<10;k++){
                ans=min(ans,dp[N][j][k][0]);
                ans=min(ans,dp[N][j][k][1]);
            }
        }
        
        cout<<ans<<endl;
    }
}




Measured memory_bytes: 81416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n;
	cin>>n;
	string s=to_string(n);
	ll ans=0;
	if(s.size()==1)ans=n;
	if(s.size()==2)ans=9;
	if(s.size()==3)ans=n-90;
	if(s.size()==4)ans=909;
	if(s.size()==5)ans=n-9090;
	if(s.size()==6)ans=90909;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,k,f,g,v[50],c[50],x;
	scanf("%d",&n);
	for (int i = 0; i < n; ++i)
		{
			scanf("%d",&v[i]);
		}
	for (int j = 0; j < n; ++j)
		{
			scanf("%d",&c[j]);
		}
	for (int k = 0; k < n; ++k)
		{
			x=v[k]-c[k];
			if (x>=0)
			{
				f=f+v[k];
				g=g+c[k];
			}
		}
		printf("%d\n",f-g);
}

Measured memory_bytes: 128
n=int(input());lista_1=[];contador=0;index=0
lista=list(map(int,input().split()))
for i in range(1,n+1):
    lista_1.append(i)
for j in lista:
    aaa=lista_1[index]
    if(j!=aaa):
        contador=contador+1
    index=index+1
if(contador<=2):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
import sys
f=lambda:map(int,sys.stdin.readline().split())
h,n=f()
dp=[10**9]*(h+1)
dp[0]=0
for i in range(n):
  a,b=f()
  for j in range(h+1):
    dp[j]=min(dp[j],dp[max(j-a,0)]+b)
print(dp[h])

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

#define MAXN 100000
/*
bool check1(int *a, int n);
bool check2(int *a, int n);

int main()
{
    int n, i, a[MAXN];
    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
       scanf("%d", &a[i]);
    }
    if(check1(a, n) == false)
        printf("No");
    else
        printf("Yes");
}
bool check1(int * a, int n)
{
   int *p, i;
   if(check2(a, n) == false)
        return false;
    else
    {
        for(i = 0; i < n; i++)
        {
           *p = * (a + n);
           * (a + n) = * (a + i);
           * (a + i) = * p;
           if(check1(a, n-1) == false || a[n-2] * a[n-1] % 4 != 0)
              return false;
           *p = * (a + n);
           * (a + n) = * (a + i);
           * (a + i) = * p;
        }
    }
    return true;
}
bool check2(int * a, int n)
{
    int i;
    for(i = 1; i < n - 1; i++)
    {
        if(a[i] * a[i-1] % 4 != 0 || a[i] * a[i+1] % 4 != 0)
            return false;
    }
    if(a[0] * a[1] % 4 != 0 )
        return false;
    return true;
}
*/
int main()
{
    int n, i, a[MAXN], a4 = 0, a2 = 0, a1 = 0;
    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
       scanf("%d", &a[i]);
       if(a[i] % 4 == 0)
        a4++;
       if(a[i] % 2 == 0 && a[i] % 4 != 0)
        a2++;
       if(a[i] % 2 != 0)
        a1++;
    }
    if(a4 >= a1)
    {
          printf("Yes\n");
    }
    else
    {
        if(a4 == a1 - 1 && a2 == 0 )
            printf("Yes\n");
        else
            printf("No\n");
    }
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include "math.h"


using namespace std;

int main()
{
	int n, m;
	cin >> n;
	cin >> m;
	int* a = new int[m+1];
	for (int i = 0; i < m+1; i++) {
		a[i] = n;
	}
	int morai = 0;
	for (int i = 0; i < n; i++) {
		int k = 0;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> morai;
			a[morai]--;
		}
	}
	int cnt = 0;
	for (int i = 0; i < m + 1; i++) {
		if (a[i] == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  string s,r;
  int ans=0;
  for(int i=a;i<=b;i++){
    r = s = to_string(i);
    reverse(r.begin(),r.end());
    if(s==r)ans++;
  }
  cout << ans << endl;
}
    


Measured memory_bytes: 256
import Data.List

collect [] = []
collect list@(x:xs) = a : (collect b)
  where
    (a,b) = span (== x) list

main = do
  s <- getLine

  let col = (map length (collect s))
  let acc = scanl (+) 0 col
  let n = length s

  print $ maximum $ f col acc n

  where
    f _ [] _ = []
    f [] _ _ = []
    f (x:xs) (y1:y2:ys) n = min (x+y1) (x+(n-y2)) : (f xs (y2:ys) n)


Measured memory_bytes: 8572
#include <array>
#include <iostream>

int main()
{
    int n;
    std::cin >> n;
    std::array<int, 20> p;
    for (int a = 0; a < n; ++a) {
        std::cin >> p.at(a);
    }
    int i = 0;
    int j;
    for (j = 1; j < n - 1; ++j) {
        if (p.at(j + 1) == 0) {
            break;
        } else if (p.at(j - 1) <= p.at(j) && p.at(j) <= p.at(j + 1)) {
            ++i;
        } else if (p.at(j + 1) <= p.at(j) && p.at(j) <= p.at(j - 1)) {
            ++i;
        }
    }
    std::cout << i << std::endl;
    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
S = readlines.map { _1.chomp.chars.sort }
S.map! { _1.group_by(&:itself) }

ans = []
S[0].each do |k,v|
  cnt = v.size
  S.each do |s|
    if s[k]
      cnt = [cnt, s[k].size].min
    else
      cnt = 0
      break
    end
  end
  ans.push(*v[0,cnt])
end
puts ans.join

Measured memory_bytes: 14280
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    int n;
    ll rta=0;
    cin >> n;
    int alturas[n+1];
    alturas[0]=0;
    map<int,int> comprobantes;
    for(int i=1;i<n+1;i++){
        cin >> alturas[i];
    }
    for(int i=1;i<n+1;i++){
        if(i-alturas[i]>1) comprobantes[i-alturas[i]]++;
    }
    for(int i=1;i<n+1;i++){
        if(comprobantes.count(alturas[i]+i)) rta+=comprobantes[alturas[i]+i];
    }
    cout << rta << endl;
    return 0;
}


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


int main(void) {
    using namespace std;

    constexpr long MOD = 1e9 + 7;

    long n;
    cin >> n;
    string s;
    cin >> s;

    vector<vector<long>> l(n+1, vector<long>(26));
    l[0][s[0]-'a'] = 1;
    for(int i=0; i<n; i++)
        for(int j=0; j<26; j++)
            l[i+1][j] = l[i][j] + (s[i+1]-'a' == j);

    long r = 0;
    for(int i=0; i<n; i++) {
        long ll = 1;
        if(i-1 >= 0)
            for(int j=0; j<26; j++)
                if (j != s[i]-'a')
                    ll *= l[i-1][j]+1, ll %= MOD;

        r += ll, r %= MOD;
    }

    cout << r << endl;

}


Measured memory_bytes: 24576
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, m;
    string s;
    cin >> n >> m >> s;

    int i = n;
    stack<int> st;
    while (i > 0) {
        bool ok = false;
        for (int j = m; j >= 1; j--) {
            if (i-j >= 0 && s[i-j] == '0') {
                ok = true;
                st.push(j);
                i -= j;
                break;
            }
        }
        if (!ok) {
            cout << -1 << endl;
            return 0;
        }
    }
    while (!st.empty()) {
        int top = st.top();
        st.pop();
        cout << top << " ";
    }
    cout << endl;
}


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

using namespace std;

using par = pair<uint64_t, uint64_t>;

bool Compare(par X, par Y)
{
  return X.second < Y.second;
}

int main()
{
  uint64_t N;
  cin >> N;
  vector<par> AB;
  AB.resize(N);

  for(uint64_t i = 0;
      i < N;
      ++i)
    {
      cin >> AB[i].first >> AB[i].second;
    }

  sort(AB.begin(), AB.end(), Compare);

  uint64_t sum = 0;

  for(uint64_t i = 0;
      i < N;
      ++i)
    {
      sum += AB[i].first;
      if(sum > AB[i].second)
        {
          cout << "No" << endl;
          return 0;
        }
    }
  cout << "Yes" << endl;
  return 0;
}


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

using namespace std;

const int N = 100010;

int a[N];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int first = 0, second = 0;
  for (int i = n - 1; i > 0; i--) {
    if (a[i] == a[i - 1]) {
      if (! first) first = a[i];
      else if (! second) second = a[i];
      i--;
    }
  }
  cout << first * 1LL * second << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define _abs(x)((x) < 0 ? (x) * -1 : (x))
#define _max(x, y)(max(0, max((x), (y))))
#define _min(x, y)(max(0, min((x), (y))))

static const ll MOD = 1e9 + 7;

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

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

    long n;

    cin >> n;

    map<ll, int> table;
    ll a;

    while (n--) {
        cin >> a;

        if (table.find(a) == table.end()) table[a] = 1;
        else table.erase(a);
    }

    cout << table.size() << endl;

    return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	int tmp = 0;
	REP(i, n)
	{
		if (s[i] == 'I')
		{
			chmax(ans, ++tmp);
		}
		else
			--tmp;
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N = int(input())
A = list(map(int,input().split()))

M = {}
for a in A:
    try:
        M[a-1]+=1
    except KeyError:
        M[a-1]=1
for x in range(N):
    try:
        print(M[x])
    except KeyError:
        print(0)
        
    

Measured memory_bytes: 38928
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }

string to_ID(ll i){
  string ret=to_string(i);
  ll num=6LL-ret.size();
  string mae=""; rep(i,num) mae+='0';
  
  return mae+ret;
}


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,M; cin>>N>>M;
  vector<ll> P(M),Y(M); rep(i,M) cin>>P[i]>>Y[i];
  
  vector<vector<pair<ll,ll>>> vec(N+1,vector<pair<ll,ll>>(0));
  rep(i,M) vec[P[i]].push_back({Y[i],i});
  
  for(auto &v:vec) sort(v.begin(),v.end());
  
  vector<pair<ll,ll>> ans_list(M);
  ll ssz=vec.size();
  rep(p,ssz){
    auto v=vec[p];
    ll sz=v.size();
    rep(j,sz){
      ll y,i; tie(y,i)=v[j];
      ans_list[i]={p,j+1};
    }
  }
  
  for(auto p:ans_list){
    ll P,x; tie(P,x)=p;
    cout<<to_ID(P)<<to_ID(x)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 11852
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>
#include <time.h>


/// Bismillahir Rahmanir Rahim



int main(void)
{
    double l;

    scanf("%lf", &l);
    double a = l / 3.0;
    printf("%lf\n", a*a*a);


    return 0;
}



Measured memory_bytes: 128
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    private static StringTokenizer st;

    private static int readInt() throws IOException {
        while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    private static int[] readIntArray(final int n) throws IOException {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = readInt();
        return a;
    }

    public static void main(String[] args) throws IOException {
        pw.println(solve(readIntArray(readInt())));
        pw.close();
    }

    private static long solve(int[] a) {
        int n = a.length;

        long res = 0;
        int max = a[0];
        for (int i = 1; i < n; i++) {
            if (a[i] < max) {
                res += max - a[i];
            } else {
                max = a[i];
            }
        }

        return res;
    }
}

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

bool solve(string s) {
	if (s == "ABC")return true;
	bool flag = false;
	set<char> c; int l = s.length();
	for (int i = 0; i < l; ++i) {
		if (i > l - 3) {
			c.insert(s[i]);
			continue;
		}
		if (s.substr(i, 3) == "ABC") {
			s.replace(i, 3, "*"); l -= 2;
			flag = true;
		}
		else c.insert(s[i]);
	}
	if (c.size() != 2)return false;
	int buf = 0;
	for (auto x : c)buf += x;
	c.clear();
	char rc = 'A' + 'B' + 'C' - buf;
	for (auto& x : s)if (x == '*')x = rc;
	if (flag)return solve(s);
	else return false;
}

int main() {
	string s;
	cin >> s;
	if (solve(s))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 9560
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define maxn 2020
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define dow(i,l,r) for(int i=r;i>=l;i--)
#define LL long long
using namespace std;

int n,tot[4];
LL w,num[4][maxn],sum[4][maxn];

int main()
{	
	scanf("%d %lld",&n,&w);
	LL base,v;
	scanf("%lld %lld",&base,&v);
	num[0][tot[0]++]=v;
	rep(i,2,n) {
		LL j,k; 
		scanf("%lld %lld",&j,&k);
		int l=(int)(j-base);
		num[l][tot[l]++]=k;
	}
	rep(i,0,3) sort(num[i],num[i]+tot[i]);
	memset(sum,0,sizeof(sum));
	dow(i,0,3)
		dow(j,0,tot[i]-1) 
			sum[i][tot[i]-j]=sum[i][tot[i]-j-1]+num[i][j];
	LL ans=0;
	rep(i,0,tot[0]) 
		rep(j,0,tot[1])
			rep(k,0,tot[2])
				rep(l,0,tot[3]) {
					LL now=(i+j+k+l)*base+j+2*k+3*l;
					if (now>w) break;
					ans=max(ans,sum[0][i]+sum[1][j]+sum[2][k]+sum[3][l]);
				}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <functional>
using namespace std;

int main(void) {
	int D, N;
	cin >> D>>N;
	if (D == 0) {
		if (N != 100)
			cout << N << endl;
		else
			cout << "101" << endl;
	}
	if (D == 1) {
		if (N != 100)
			cout << N*100 << endl;
		else
			cout << "10100" << endl;
	}
	if (D == 2) {
		if (N != 100)
			cout << N*10000 << endl;
		else
			cout << "1010000" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
a, b = gets.split.map &:to_i
l = a.lcm(b)
g = a.gcd(b)
if a % b == 0then
  p -1
else
  n = a * g
  while n % b == 0 do
    n *= g
    if l < n then
      n = a * a / g
      break
    end
  end
  p n
end

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

int main() {
    ll A, B;
    cin >> A >> B;
    ll ans = 0;
    if (A >= 13)
        ans = B;
    else if (A >= 6)
        ans = B / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for(int i = 1, i##_len = (n); i <= i##_len; ++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 INF 1000000000000
#define MOD 1000000007

using namespace std;
using ll = long long;

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

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int h, w;
	cin >>h >>w;
	vector<string> vs(h);
	rep(i, h) cin >>vs[i];
	vector<VI> p(h, VI(w));
	
	auto f=[&](VI& v){
		int n = sz(v);
		rep2(i, 1, n) if(v[i]==1) v[i] = v[i-1] +1;
		repr(i, n-2, 0) if(v[i]>0 && v[i]<v[i+1]) v[i]=v[i+1];
	};
	
	rep(i, h){
		VI cr(w);
		rep(j, w) if(vs[i][j]=='.') cr[j] = 1;
		f(cr);
		//for(auto x :cr) cerr<<x<<" "; dbg();
		rep(j, w) p[i][j] += cr[j];
	}
	rep(i, w){
		VI cr(h);
		rep(j, h) if(vs[j][i]=='.') cr[j] = 1;
		f(cr);
		rep(j, h) p[j][i] += cr[j];
	}
	int ans = 0;
	rep(i, h) rep(j, w) ans = max(ans, p[i][j]);
	cout << (ans? ans -1: 0) <<"\n";
	return 0;
}


Measured memory_bytes: 20224
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define pb push_back
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,k,n) for(int i=k;i<n;i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> iv;
typedef pair<int,int> iip;
typedef map<int,int> mii;
template <typename T>
void dbg(T t){cerr<<t<<endl ;}
template<typename T, typename... Args>
void dbg(T t, Args... args) {cerr << t <<" ";dbg(args...) ;}

int main(){
	int n;
	string s;
	cin>>s;
	char c= s.front(),d = s.back();
	n= s.size()-2;
	printf("%c%d%c\n",c,n,d);
	return 0;
 }

Measured memory_bytes: 256
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using mint = modint;

int op(int a, int b){
	return max(a,b);
}
int e(){
	return -1;
}
int th;
bool f(int v){
	if(v<th) return 1;
	return 0;
}

int main(){
	fastio;
	mint::set_mod(MOD);

	int n, q; 
	cin>>n>>q;
	int a[n];
	forn(i,n) cin>>a[i];

	segtree<int, op, e> seg(n);

	forn(i,n) seg.set(i, a[i]);
	forn(i,q){
		int t; cin>>t;
		if(t == 1){
			int x, v;
			cin>>x>>v;
			x--;
			seg.set(x,v);
		}
		else if(t == 2){
			int l, r; 
			cin>>l>>r;
			l--;
			r--;
			r++;
			cout<<seg.prod(l,r)<<ln;
		}
		else{
			int x;
			cin>>x>>th;
			x--;
			int ans = seg.max_right(x, f);
			cout<<ans+1<<ln;
		}
	}

	return 0;
}

Measured memory_bytes: 6908
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(void) {
	int i, j, m, d, ans = 0;
	cin >> m >> d;
	for (i = 1; i <= m; i++) {
		for (j = 20; j <= d; j++) {
			if (i == (j / 10) * (j % 10) && (j % 10) > 1)
				ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n+1];
  for(int i=1;i<=n;i++){
    cin >> a[i];
  }
  int l=1;
  for(int i=0;i<n;i++){
    l=a[l];
    if(l==2) {
      cout << i+1<<endl;
      return 0;
    }
  }
 cout << -1<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll i,j,t,q,l,r;
bool b[N];
ll c[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    rep(i,2,N) b[i] = 1;
    rep(i,2,N) if(b[i]){
        for(j = i + i;j < N;j+=i) b[j] = 0;
    }
    for(i = 2;i < N;i++){
        t = 0;
        if(i&1)
            t = b[i] and b[(i + 1)/2];
        c[i] = c[i - 1] + t;
    }
    cin>>q;
    while(q--){
        cin>>l>>r;
        cout<<c[r] - c[l - 1]<<endl;
    }
    return 0;
}

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

#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int(i) = 0; (i) < (int)(n); ++(i))
#define rep_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) < (int)(n); ++(i))
#define rep(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int(i) = (int)(n); (i) > 0; (i)--)
#define rep_r_3(i, initial, n) \
  for (int(i) = (int)(initial); (i) > (int)(n); (i)--)
#define rep_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define type definition
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int;  // 多倍長整数（任意精度）
typedef pair<int, int> P;

// define construct variable
const double EPS = numeric_limits<double>::epsilon();
// 10^9 + 7
const ll MOD = ll(1e9) + 7;
const ll INF = ll(1e10);
const string ALPHABET = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1);

// define methods
// 最大公約数
ll gcd(const ll a, const ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(const ll a, const ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> p;
  for (ll i = 2; i * i <= n; i++) {
    if ((n % i) != 0) continue;
    pair<ll, ll> a = make_pair(i, 0);
    while ((n % i) == 0) {
      n /= i;
      a.second += 1;
    }
    p.push_back(a);
  }

  if (n != 1) p.push_back(make_pair(n, 1));
  return p;
}
// 組み合わせの整合性を保つ（後ほど解析する）
ll modinv(ll a) {
  ll b = MOD, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= MOD;
  if (u < 0) {
    u += MOD;
  }
  return u;
}
// 順列
ll permutation(const ll n, const ll m) {
  ll result = 1;
  for (ll i = n; i > n - m; i--) {
    result = (result * i) % MOD;
  }
  return result;
}

// 繰り返し n 乗法
ll repeat_square(const ll n, const ll x) {
  if (x == 0) return 1;
  ll res = repeat_square(n, x / 2);
  res = res * res % MOD;
  if ((x % 2) == 1) res = res * n % MOD;
  return res;
}
// 組み合わせ nCm
ll combination(ll n, ll m) {
  ll p = permutation(n, m);
  ll div = 1;
  for (ll i = 2; i <= m; i++) {
    div = (div * i) % MOD;
  }
  return (p * modinv(div)) % MOD;
}

// アルファベットの取得
string get_alphabet(ll n) {
  n--;
  return string(1, 'a' + (n % 26));
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N, 0);
  rep(i, N) {
    int a;
    cin >> a; a--;
    A[a]++;
  }

  sort(A.begin(), A.end());

  int ans = 0;
  rep(i, A.size()) {
    if (A[i] == 0) continue;

    int check = 0, prev = -1;
    rep(j, i, A.size()) {
      check++;
    }
    if (check <= K) break;
    ans += A[i];
  }

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


Measured memory_bytes: 3960
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    for(int a = 1; a < N; a++) {
        int cntb = (N - a) / K;
    }
    int cnt = 0;
    // REP(a, 1, N) {
    //     REP(b, 1, N) {
    //         REP(c, 1, N) {
    //             if ((a + b) % K == 0 && (b + c) % K == 0 && (c + a) % K == 0) {
    //                 cout << a << " "<< b << " " << c << endl;
    //                 cnt++;
    //             }
    //         }
    //     }
    // }
    // cout << cnt << endl;
    if (K % 2 == 0) {
        int ans1 = ((N + K/2)/K) * ((N + K/2)/K) * ((N + K/2)/K);
        int ans2 = (N/K) * (N/K) * (N/K);
        cout << ans1 + ans2 << endl;
    } else {
        cout << (N/K) * (N/K) * (N/K) << endl;
    }

    return 0;
}


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

int main(){
    string s;
    int i,j;
    cin >> s;
    for(i=0;i<s.size();i++){
        if(s[i]=='A')break;
    }
    for(j=s.size()-1;j>=0;j--){
        if(s[j]=='Z')break;
    }
    cout << j-i+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
//9:34

int main(){
  int a[3] = {};
  int b[3] = {};
  int c[3] = {};
  int i = 0;
  int bflag = 0;
  int cflag = 0;
  int diff = 0;
  
  scanf("%d %d %d",&a[1],&a[2],&a[3]);
  scanf("%d %d %d",&b[1],&b[2],&b[3]);
  scanf("%d %d %d",&c[1],&c[2],&c[3]);
  
  if(b[1]-a[1] == b[2] - a[2] && b[2]-a[2] == b[3]-a[3]){
    bflag = 1;
  }else{
    bflag = 0;
  }
     
  if(c[1]-a[1] == c[2] - a[2] && c[2]-a[2] == c[3]-a[3]){
    cflag = 1;
  }else{
    cflag = 0;
  }
  
  
  if(bflag && cflag){
  	printf("Yes");
  }else{
    printf("No");
  }
	return 0;
}
     


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; k < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  bool N = false,W =false,S=false,E=false;
  rep(i,sz(s)) {
    if(s[i] == 'N') N = true;
    if(s[i] == 'W') W = true;
    if(s[i] == 'S') S = true;
    if(s[i] == 'E') E = true;
  }
  if((N && !S) || (!N && S) || (W && !E) || (!W && E)) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

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

int main() {
	//freopen("input.txt", "rt", stdin);

	int N;
	cin >> N;

	int W;
	cin >> W;

	vector<int> w(N);
	vector<int> v(N);

	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	
	vector<vector<long long>> dp(N + 1, vector<long long>(W + 1, 0));

	for(int i = 1; i <= N; i++)
		for (int j = 0; j <= W; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j >= w[i - 1])
				dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
		}

	cout << dp[N][W];
	return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
    scanf("%d",&n);
    while(n--){
        int x;
        scanf("%d",&x);
        if(x%2==0){
            if(x%3&&x%5){
                printf("DENIED");
                return 0;
            }
        }
    }
    printf("APPROVED");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N=105;
int n,m,K,i,j,k,l,mo,mi[N][N*N],f[2][N][N],h[N][N],fac[N],inv[N],vf[N],nw,ans,w[N][N];
int main(){
	scanf("%d%d%d%d",&n,&m,&K,&mo);
	for(i=*fac=*vf=1;i<N;++i)
		fac[i]=1ll*fac[i-1]*i%mo,
		inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo,
		vf[i]=1ll*vf[i-1]*inv[i]%mo;
	for(i=0;i<N;++i)for(j=*mi[i]=1;j<N*N;++j)mi[i][j]=1ll*mi[i][j-1]*i%mo;
	f[0][0][0]=1;
	for(i=K;i;--i){
/*
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(k=0;k<=m;++k)for(l=0;l<=n;++l)w[k][l]=1ll*mi[K-i+1][l*(m-k)]*vf[l]%mo*mi[i][l*k]%mo;
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;j+l<=n;++l)
			f[nw][j+l][k]=(f[nw][j+l][k]+1ll*w[k][l]*f[!nw][j][k])%mo;
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;j<=n;++j)for(l=0;l<=m;++l)w[j][l]=1ll*mi[K-i+1][l*(n-j)]*vf[l]%mo*mi[i][l*j]%mo;
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;l+k<=m;++l)
			f[nw][j][l+k]=(f[nw][j][l+k]+1ll*w[j][l]*f[!nw][j][k])%mo;
*/
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;j+l<=n;++l)
			f[nw][j+l][k]=(f[nw][j+l][k]+1ll*mi[K-i+1][l*(m-k)]*vf[l]%mo*mi[i][l*k]%mo*f[!nw][j][k])%mo;
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;l+k<=m;++l)
			f[nw][j][l+k]=(f[nw][j][l+k]+1ll*mi[K-i+1][l*(n-j)]*vf[l]%mo*mi[i][l*j]%mo*f[!nw][j][k])%mo;
/*
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;j+l<=n;++l)
			f[nw][j+l][k]=(f[nw][j+l][k]+1ll*mi[K-i+1][l*(m-k)]*(l&1?mo-vf[l]:vf[l])%mo*mi[i-1][l*k]%mo*f[!nw][j][k])%mo;
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;l+k<=m;++l)
			f[nw][j][l+k]=(f[nw][j][l+k]+1ll*mi[K-i+1][l*(n-j)]*(l&1?mo-vf[l]:vf[l])%mo*mi[i-1][l*j]%mo*f[!nw][j][k])%mo;
*/
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(k=0;k<=m;++k)for(l=0;l<=n;++l)w[k][l]=1ll*mi[K-i+1][l*(m-k)]*(l&1?mo-vf[l]:vf[l])%mo*mi[i-1][l*k]%mo;
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;j+l<=n;++l)
			f[nw][j+l][k]=(f[nw][j+l][k]+1ll*w[k][l]*f[!nw][j][k])%mo;
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;j<=n;++j)for(l=0;l<=m;++l)w[j][l]=1ll*mi[K-i+1][l*(n-j)]*(l&1?mo-vf[l]:vf[l])%mo*mi[i-1][l*j]%mo;
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;l+k<=m;++l)
			f[nw][j][l+k]=(f[nw][j][l+k]+1ll*w[j][l]*f[!nw][j][k])%mo;
/*
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;j+l<=n;++l)
			f[nw][j+l][k]=(f[nw][j+l][k]+1ll*mi[K-i+1][l*(m-k)]*(l&1?mo-vf[l]:vf[l])%mo*mi[i-1][l*k]%mo*f[!nw][j][k])%mo;
		nw^=1;memset(f[nw],0,sizeof f[nw]);
		for(j=0;j<=n;++j)for(k=0;k<=m;++k)for(l=0;l+k<=m;++l)
			f[nw][j][l+k]=(f[nw][j][l+k]+1ll*mi[K-i+1][l*(n-j)]*(l&1?mo-vf[l]:vf[l])%mo*mi[i-1][l*j]%mo*f[!nw][j][k])%mo;
*/
	}
	ans=f[nw][n][m];
	ans=1ll*fac[n]*fac[m]%mo*ans%mo;
	printf("%d\n",ans);
	return 0;
}

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

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

using namespace std;

const int INF=1<<29;

int main(){
	int f[]={6,2,5,5,4,5,6,3,7,6};

	int n,m; cin>>n>>m;
	vector<int> a(m);
	rep(i,m) cin>>a[i];
	sort(a.begin(),a.end());

	pair<int,int> dp[10001];
	int pre[10001];
	rep(i,n) dp[i+1]={-1,0};
	for(int d:a){
		int cost=f[d];
		rep(i,n-cost+1) if(~dp[i].first) {
			pair<int,int> next={dp[i].first+1,d};
			if(dp[i+cost]<next){
				dp[i+cost]=next;
				pre[i+cost]=i;
			}
		}
	}

	int i=n;
	do{
		putchar('0'+dp[i].second);
		i=pre[i];
	}while(i>0);

	return 0;
}


Measured memory_bytes: 384
# from collections import Counter, defaultdict
# n = int(input())
# li = list(map(int, input().split()))
# n = int(input())
# a, b = map(int, input().split())
# d = defaultdict(lambda: 0)
li = ["SUN", "MON", "TUE", 'WED', "THU", "FRI", "SAT"]
s = input()
print(7-li.index(s))

Measured memory_bytes: 61752
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define MP make_pair
#define PB push_back
typedef long long LL;
const LL MOD = 998244353;
const int N = 2e5+10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,fa[N];

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	rep(i,0,20){
		if((1<<i)==n){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes\n";
	if(n==3){
		rep(i,2,6)cout<<i-1<<" "<<i<<endl;
		return 0;
	}
	int k=1;
	while(k<n)k<<=1;
	k>>=1;
	rep(i,2,k-1)fa[i]=i-1;
	fa[n+1]=k-1;
	rep(i,n+2,n+k-1)fa[i]=i-1;
	for(int i=k;i<n;i+=2){
		fa[i]=2;fa[i+1]=i;
		fa[n+i]=n+i+1;fa[n+i+1]=k-1;
	}
	if(n%2==0){
		int tmp = (n-k)^2;
		if(tmp==0){
			fa[n]=k;fa[n+n]=2;
		}else{
			fa[tmp]=2;
			fa[tmp+1]=tmp-1;
			fa[3]=tmp;
			
			fa[n+tmp]=n+2;
			fa[n+tmp+1]=n+tmp-1;
			fa[n+3]=n+tmp;
			
			fa[n]=k;fa[n+n]=tmp;
		}
	}
	rep(i,2,n*2)cout<<fa[i]<<" "<<i<<endl;
	return 0;
}

Measured memory_bytes: 3456
s = input().split()
x = int(s[0])
y = int(s[1])

list = []
for i in range(x):
  list.append('n')
for i in range(y):
  list.append('m')
  
result = []
for i in range(len(list)):
  for j in range(i + 1, len(list)):
      result.append([list[i], list[j]])
      
count = 0
for i in range(len(result)):
  if result[i][0] == result[i][1]:
    count += 1

print(count)




Measured memory_bytes: 4980
class Dice
	attr_reader :pips

  def initialize(ary)
    @pips = ary
  end

  def _rot(ary, r)
		vals = ary.rotate(r).map{ |i| @pips[i-1] }
		ary.zip(vals).each{ |i, v| @pips[i-1] = v }
  end

	def rotate(ch)
    case ch
    when 'N'
      _rot([1, 2, 6, 5], +1)
    when 'S'
      _rot([1, 2, 6, 5], -1)
    when 'E'
      _rot([1, 4, 6, 3], +1)
    when 'W'
      _rot([1, 4, 6, 3], -1)
    when 'Z'
      _rot([2, 3, 5, 4], +1)
    end
	end

	def equal(other_dice)
		4.times do
      4.times do
				rotate('Z')
				return true if @pips == other_dice.pips
			end
      rotate('N')
    end
    rotate('E')
    4.times do
			rotate('Z')
			return true if @pips == other_dice.pips
		end
    rotate('W')
    rotate('W')
    4.times do
			rotate('Z')
			return true if @pips == other_dice.pips
		end
    return false
	end
end

n = gets.chomp.to_i
dices = []
n.times{ dices << Dice.new(gets.chomp.split(/\s/).map(&:to_i)) }

(0..(n-2)).each do |i|
	((i+1)..(n-1)).each do |j|
		if dices[i].equal(dices[j])
			puts 'No'
			exit
		end
	end
end
puts 'Yes'

Measured memory_bytes: 8976
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b[110000];
string s;
char c;
pair<int,int> p[110000];
signed main()
{
	cin>>a;
	cout<<a*a*a;
}

Measured memory_bytes: 256
from math import ceil
def fanc(x):
    return int((ceil(x/10))*10)
ans = 0
menu = [int(input()) for _ in range(5)]
menu.sort(key=lambda x:x%10)
for i in range(5):
    if menu[i]%10:
        ans += menu.pop(i)
        break
menu = list(map(fanc, menu))
print(ans+sum(menu))

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

int n, k, a[200005];

bool ok(int c) {
  int cnt = 0;
  for (int i = 0; i < n; i++) cnt += a[i] / c;
  return cnt <= k;
}

int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }
  int l = 0, r = 1001001001;
  while (r - l > 1) {
    int c = (l + r) / 2;
    (ok(c) ? r : l) = c;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4340
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn read_int_tuple() -> (i32, i32, i32) {
    let v = read_vec();
    (v[0], v[1], v[2])
}

fn main() {
    let (N, K, Q) = read_int_tuple();
    let mut points = vec![K-Q; N as usize];
    for i in 0..Q {
        let A: i32 = read_line().parse().unwrap();
        points[(A-1) as usize] += 1;
    }
    for i in points {
        if i > 0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 4732
// Template {{{
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}


vector<int> A;
map<int, vector<int>> rev;
int dfs(int x) {
    vector<int> res;
    for(int y : rev[x]) {
        res.push_back(dfs(y));
    }
    sort(res.begin(), res.end());
    reverse(res.begin(), res.end());
    int ans = A[x];
    REP(i, res.size()) {
        ans = max(ans, res[i]+1+i);
    }
    return ans;
}

int main(){
    iostream_init();
    int N;
    while(cin >> N) {
        vector<int> d(N);
        for(int i = 1; i < N; i++) {
            cin >> d[i];
            d[i]--;
        }

        A.assign(N, 0);

        rev.clear();
        for(int i = 1; i < N; i++) {
            A[d[i]]++;
            rev[d[i]].push_back(i);
        }

        const int ans = dfs(0);
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 22912