akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;



int solve_testcase(){
	int n;
	cin >> n;
	vector<array<int, 2>> left, right;
	long long res = 0;
	for(auto i = 0; i < n; ++ i){
		int k, l, r;
		cin >> k >> l >> r;
		res += min(l, r);
		if(l >= r){
			left.push_back({k, l - r});
		}
		else{
			right.push_back({k, r - l});
		}
	}
	int lcnt = int(left.size());
	sort(left.begin(), left.end());
	multiset<int> ms;
	for(auto i = lcnt - 1; i >= 0; -- i){
		while(!left.empty() && left.back()[0] > i){
			ms.insert(left.back()[1]);
			left.pop_back();
		}
		if(!ms.empty()){
			res += *ms.rbegin();
			ms.erase(prev(ms.end()));
		}
	}
	sort(right.rbegin(), right.rend());
	ms.clear();
	for(auto i = lcnt; i < n; ++ i){
		while(!right.empty() && right.back()[0] <= i){
			ms.insert(right.back()[1]);
			right.pop_back();
		}
		if(!ms.empty()){
			res += *ms.rbegin();
			ms.erase(prev(ms.end()));
		}
	}
	cout << res << "\n";
	return 0;
}

int main(){
	cin.tie(0)->sync_with_stdio(0);
	int ttt;
	cin >> ttt;
	while(ttt --){
		solve_testcase();
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 9316
#include <bits/stdc++.h>
using namespace std;
long long n,srx[101];
int i;
long long f(long long n)
{
    if(srx[n])
    return srx[n];
    if(n>0)
    srx[n]=f(n-1)*2+2;
}
int main()
{
    scanf("%d",&n);
    srx[0]=2;
    f(n);
    printf("%lld\n",srx[n]);
}

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


int main(){
    int n,m;

    cin>>n;
    vector<string> v;


    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        v.push_back(s);
    }

    cin>>m;
    int count=0;

    for(int i=0;i<m;i++){
        
        bool flag=false;
        string t;
        cin>>t;

        for(int j=0;j<v.size();j++){
            if(t==v[j]){
                flag=true;
                if(count%2==0){
                    cout<<"Opened by "<<t<<endl;
                    count++;
                    break;
                }else if(count%2==1){
                    cout<<"Closed by "<<t<<endl;
                    count++;
                    break;
                }
            }
        }
        if(!flag){
            cout<<"Unknown "<<t<<endl;
        }
    }
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);

  ll ans = 0;
  while (X <= Y) {
    ans++;
    X *= 2;
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

template <class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
    ll n,k;
    cin >> n >> k;

    ll i=1;
    ll sum=0;

    for(i=k;i<=n+1;i++){
        ll end = (i*(2*n-i+1)/2);
        ll beg = (i*(i-1)/2);
        sum=sum + 1 + end - beg;
    }
    cout << sum%mod << endl;
    return 0;
}

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

int main(){
  int S;
  cin >> S;
  int former = S/100;
  int latter = S%100;
  
  if(1<=former && former<=12 && 1<=latter && latter<=12){
    cout << "AMBIGUOUS" << endl;
  }else if(1<=former && former<=12 && (12<latter||latter == 0)){
    cout << "MMYY" <<endl;
  }else if((12<former ||former == 0) && 1<=latter && latter<=12){
    cout << "YYMM" <<endl;
  }else{cout << "NA" << endl;
       }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
	string s;
	cin >> s;

	int len = (int)s.size();
	
	bool flag = true;

	if (s[0] != 'A') flag = false;
	if ('A' <= s[1] && s[1] <= 'Z') flag = false;

	int count = 0;

	for (int i = 2; i < len; i++){
		if (2 <= i && i <= len - 2){
			if (s[i] == 'C') count++;
			else if ('A' <= s[i] && s[i] <= 'Z') flag = false;
		}
		else if ('A' <= s[i] && s[i] <= 'Z')flag = false;
	}

	if (count != 1) flag = false;


	cout << (flag ? "AC" : "WA") << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int main(){
  long long n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);
  long long ans = (n/(a+b))*a;
  ans += std::min(n%(a+b), a);
  printf("%lld\n", ans);
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d", &a, &b, &c)

	for i := 0; i < b; i++ {
		if (a*i)%b == c {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        long a=in.nextLong();
        long b=in.nextLong();
        long k=in.nextLong();
        if(a<=k) {
            k-=a;
            a=0;
        }
        else {
            a-=k;
            k=0;
        }
        if(b<=k) {
            b=0;
        }
        else b-=k;
        System.out.println(a+" "+b);
    }
}

Measured memory_bytes: 23764
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BS
import           Data.List             (sortOn)
import           Data.Maybe            (fromJust)
import           Data.Ord              (Down (Down))
import qualified Data.Vector           as V

main :: IO ()
main = do
  n <- readLn
  as <- map readInt . BS.words <$> BS.getLine
  print $ solve n as

solve :: Int -> [Int] -> Int
solve _ as = V.sum cas - V.sum cbs where
  as' = V.fromList $ sortOn Down as
  cas = V.ifilter (\i _ -> even i) as'
  cbs = V.ifilter (\i _ -> odd i) as'

readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt


Measured memory_bytes: 508
<>=~$";
@a=glob`dd`;
for(1..$`*$'){
	if($a[$_-1]%2){
		if($_%$'){
			++$a[$_];
			push@_,$_-1,$_
		}elsif($_<$`*$'){
			++$a[$_-1+$'];
			push@_,$_-1,$_-1+$'
		}
	}
}
print@_/2,$/,map{$_/$'+1|0,$",$_%$'+1,--$|?$":$/}@_


Measured memory_bytes: 113704
def gcd(x, y):
    if x >= y:
        while y != 0:
            x, y = y, x % y
        return x
    else:
        while x != 0:
            y, x = x, y % x
        return y

N = int(input())
A = list(map(int, input().split()))
L = [0, 0]
for ai in A:
    L.append(gcd(L[-1], ai))
 
R = [0, 0]
for ai in A[::-1]:
    R.append(gcd(R[-1], ai))
 
print(max(gcd(l, r) for l, r in zip(L, reversed(R))))

Measured memory_bytes: 14584
A,B = map(int,input().split())
S = list(input())
check = [str(i) for i in range(10)]

okFlag = True
for key,val in enumerate(S):
    if key == A:
        if S[key] != '-':
            okFlag = False
        else:
            continue
    elif S[key] not in check:
        okFlag = False

if okFlag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61780
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int M, N, K;
string S[1001];
int A, B, C, D;
int I[1001][1001];
int O[1001][1001];
int J[1001][1001];
int main(){
	scanf("%d%d%d", &M, &N, &K);
	for (int i = 0; i < M; i++)cin >> S[i + 1];
	for (int i = 1; i <= M; i++){
		for (int j = 1; j <= N; j++){
			I[i][j] = I[i - 1][j] + I[i][j - 1] - I[i - 1][j - 1];
			O[i][j] = O[i - 1][j] + O[i][j - 1] - O[i - 1][j - 1];
			J[i][j] = J[i - 1][j] + J[i][j - 1] - J[i - 1][j - 1];
			if (S[i][j - 1] == 'J')J[i][j]++;
			if (S[i][j - 1] == 'O')O[i][j]++;
			if (S[i][j - 1] == 'I')I[i][j]++;
		}
	}
	for (int k = 0; k < K; k++){
		scanf("%d%d%d%d", &A, &B, &C, &D);
		printf("%d %d %d\n", J[C][D] - J[A - 1][D] - J[C][B - 1] + J[A - 1][B - 1], O[C][D] - O[A - 1][D] - O[C][B - 1] + O[A - 1][B - 1], I[C][D] - I[A - 1][D] - I[C][B - 1] + I[A - 1][B - 1]);
	}
	return 0;
}

Measured memory_bytes: 13972
//ABC153C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n, k;
	cin >> n >> k;
	vector<long long int> h(n);
	for(int i=0;i<n;i++){
		cin >> h.at(i);
	}
	long long int ans = 0;
	sort(h.begin(),h.end());
	for(int i=0;i<n-k;i++){
		ans += h.at(i);
	}
	cout << ans << endl;
	return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

int main()
{
  ll n; cin >> n;
  double d; cin >> d;
  ll cnt = 0;
  for (int i=0; i<n; i++){
    double x,y; cin>>x>>y;
    if (sqrt(x*x+y*y) <= d) cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3816
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <assert.h>
#include <string>
#define int long long
using namespace std;
int m=1000000007;
bool visited[100005];
int ans = 0;
std::vector<int> g[100005];
void dfs(int s){
  visited[s] = true;
  ans++;
  for(int i = 0; i < g[s].size(); i++){
    if(visited[g[s][i]] == false){
      dfs(g[s][i]);
    }
  }
}
int32_t main(){
	int N,k;
	cin >> N >> k;
	int arr[N+1];
	for(int i = 1; i <= N; i++){
		cin >> arr[i];
	}
	int dp[100005];
	dp[1] = 0;
	dp[2] = dp[1] + abs(arr[1] - arr[2]);
	for(int i = 3; i <= N; i++){
		if(k < i){
			dp[i] = dp[i-k] + abs(arr[i-k] - arr[i]);
			for(int j = i-k+1; j < i; j++){
				dp[i] = min(dp[i],dp[j] + abs(arr[j] - arr[i]));
			}
		}
		else{
			dp[i] = dp[1] + abs(arr[1]-arr[i]);
			for(int j = 2; j < i; j++){
				dp[i] = min(dp[i],dp[j] + abs(arr[j] - arr[i]));
			}
		}
	}
	cout << dp[N] << endl; 
}


Measured memory_bytes: 4224
/*---------------------------------- NEVER GIVE UP --------------------------------------------*/

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

typedef long long ll;
typedef double ld;
typedef pair<ll,ll> pii;
typedef tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fastt ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug1(x) cerr<<#x<<" : "<<x<<endl
#define debug2(x,y) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define debug3(x,y,z) cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl

const ll modd=1e9+7;
const ll inf=1e18;

ll poww(ll a,ll b){
  ll ans=1;
  while(b){
    if(b&1LL) ans=(ans*a);
    a=(a*a);
    b=b>>1LL;
  }
  return ans;
}

/*    
         -> mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
         -> cout<<"Case #"<<casee<<": "<<ans<<endl; // for google kickstart

*/

/*-----------------------------------------------------------------------------------------------*/

vector <pair<pii,pii>> abc;

int main(){
   fastt;
   
   string s;
   cin>>s;

   ll counta=0,countb=0,last=0,i=0;

   while(i<(ll)s.length()){
     if(counta > 0 && i+1<(ll)s.length() && s.substr(i,2) == "BC"){
       countb++;
       i+=2;
     }
     else if(counta ==0 && s[i]=='A'){
       last=i;
       counta++;
       i++;
     }
     else if(counta > 0 && countb == 0 && s[i]=='A'){
       counta++;
       i++;
     }
     else if(counta > 0 && countb != 0 && s[i]=='A'){
       if(counta > 0 && countb >0){
          abc.pb({{last,i-1},{counta,countb}});         
       }
       counta=countb=0;
       counta=1;
       last=i;
       i++;
     }
     else if(s[i] == 'B' || s[i] == 'C'){
       if(counta > 0 && countb >0){
          abc.pb({{last,i-1},{counta,countb}});         
       }
       counta=countb=0;
       i++;
     }
   }

   if(counta > 0 && countb > 0)
    abc.pb({{last,(ll)s.length()-1},{counta,countb}});


   ll ans=0;

 //  for(ll i=0;i<abc.size();i++)
 //     debug2(abc[i].fi.fi,abc[i].fi.se);

   for(ll i=0;i<(ll)abc.size();i++){
      ans+=abc[i].se.fi*abc[i].se.se;
      if(i<(ll)abc.size()-1 && abc[i].fi.se+1 == abc[i+1].fi.fi)
        abc[i+1].se.fi+=abc[i].se.fi;
   }

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


Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 998244353
 
#define fi first
#define se second
int32_t main() 
{
   string s;
   cin>>s;
   int ans = 0;
   int n=s.size();
   int c = 0;
   vec v(n);
   vec val(n,0);
   foo(i, 1, n)
   {
       
       if (((s[i - 1] - '0') >= 5) )
   {
       val[i] = 1;
      
       }
   }
       //deb1a(val);
 
       for (int i = n - 1; i >= 0; i--)
       {
           if (s[i] == '9')
           {
               if (c == 0)
                   ans++;
               s[i] = '0';
               c = 1;
           }
           else
           {
 
               s[i] += c;
 
               if (s[i] - '0' > 5)
               {
                   ans += (10 - (s[i] - '0'));
                   s[i] = '0';
                   c = 1;
               }
               else if ((s[i] - '0' == 5) && (val[i] == 1))
               {
                   ans += (10 - (s[i] - '0'));
                   s[i] = '0';
                   c = 1;
               }
               else
               {
                   c = 0;
               }
           }
   }
   ans += c;
   fo(i,n){
       ans += (s[i] - '0');
   }
   cout << ans;
} 

Measured memory_bytes: 17028
(function(input) {
    var p = input.split('\n');
    var n = Number(p.shift());
    var A = p.shift().split(' ', n).map(Number);
    var q = Number(p.shift());
    var m = p.shift().split(' ', q).map(Number);

    for (var i = 0; i < m.length; i++) {
        //console.info("n = " + i);
        console.log(check(A, 0, m[i]) ? 'yes' : 'no');
        //console.info('##########');
    }

})(require('fs').readFileSync('/dev/stdin', 'utf8'));

function check(A, i, m) {
    //console.info("i = " + i);
    //console.info("m = " + m);
    var a = A[i];
    if (m == a) {
        return true;
    }
    if (i == A.length - 1) {
        return false;
    }
    i++;
    if (m < a) {
        return check(A, i, m);
    }
    return check(A, i, m - a) || check(A, i, m);
}

Measured memory_bytes: 8956
from math import inf

n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -inf
for bit in range(1,1024):
    res = 0
    for j in range(n):
        c = 0
        for k in range(10):
            mask = 1 << k
            if f[j][k] and bit&mask:
                c+=1
        res += p[j][c]
    ans = max(ans, res)
print(ans)




Measured memory_bytes: 9156
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n, a;
  scanf("%d", &n);
  scanf("%d", &a);
  if (n%500 <= a) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <string.h>
using namespace std;

char a[10],b[10],c[10];
int main(){
  cin >> a >> b >> c;
  if((a[strlen(a)-1]==b[0])&&(b[strlen(b)-1]==c[0])){
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            String t = sc.next().replaceAll("-", "");
            String a = "" + t.charAt(0);
            for (int i = 1; i < t.length(); i += 2) {
                if (a.indexOf(t.charAt(i + 1)) == -1) {
                    if (t.charAt(i) == '>') {
                        a += t.charAt(i + 1);
                    } else {
                        a = t.charAt(i + 1) + a;
                    }
                }
            }
            System.out.println(a);
        }
    }
}


Measured memory_bytes: 31596
n=int(input())
r=list(map(int,input().split()))

result=0
negativeCount=0
minmumNumver=10**9

for item in r:
  if item<0:
    negativeCount+=1
    item=abs(item)

  result+=item
  minmumNumver=min(item,minmumNumver)

if negativeCount%2==1:

  result=result-minmumNumver*2
print(result)
    

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n, a, b, c, d;
    cin >> n >> a >> b >> c >> d, a--, b--, c--, d--;
    string s;
    cin >> s;

    if (s.substr(a, c - a + 1).find("##") != string::npos
        || s.substr(b, d - b + 1).find("##") != string::npos) {
        cout << "No" << endl;
    } else if (c < d) {
        cout << "Yes" << endl;
    } else if (s.substr(b - 1, d - b + 3).find("...") != string::npos) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    ll n;
    cin>>n;
    vector<vector<P>> v(n);
    for(ll i=0;i<n-1;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        v[a].push_back({b,c});
        v[b].push_back({a,c});        
    } 
    vector<ll> col(n),visit(n);
    queue<ll> q;
    col[0]=0;
    q.push(0);
    visit[0]=1;
    while(q.empty()!=1){
        ll tmp=q.front(); 
        q.pop();
        for(ll j=0;j<v[tmp].size();j++){
            ll a=v[tmp][j].first,b=v[tmp][j].second;
            if(visit[a]==0){
                if(b%2==0) col[a]=col[tmp];
                else col[a]=1-col[tmp];
                q.push(a);
                visit[a]=1;
            }
        }
    }
    for(ll i=0;i<n;i++){
        cout<<col[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 9472
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
    long long dp[2][2019] = {};
    int length;
    char str[200010];

    scanf("%s", str);

    length = (int)(strlen(str));

    long long res = 0;

    for (int i = 0; i < length; ++i) {
        long long *current = dp[i % 2];
        long long *prev = dp[(i + 1) % 2];

        for (int j = 0; j < 2019; ++j) {
            current[j] = 0;
        }

        int digit = (int)(str[i] - '0');

        current[digit] = 1;

        for (int j = 0; j < 2019; ++j) {
            current[(j * 10 + digit) % 2019] += prev[j];
        }

        res += current[0];
    }

    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 1880
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

ll dp[101][5][5][5] = {};
//0:dammy, 1:A, 2:, 3:G, 4:T
//AGC, GAC, ACG, A*GC, AG*Cを含まない(123, 213, 132がダメ)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int N;
	cin >> N;

	dp[0][0][0][0] = 1;
	rep(n, N) {
		rep(i, 5) {
			rep(j, 5) {
				rep(k, 5) {
					for(int l = 1; l < 5; l++) {
						if (i == 1 && j == 2 && l == 3) {
							continue;
						}
						if (i == 1 && k == 2 && l == 3) {
							continue;
						}
						if (j == 1 && k == 2 && l == 3) {
							continue;
						}
						if (j == 2 && k == 1 && l == 3) {
							continue;
						}
						if (j == 1 && k == 3 && l == 2) {
							continue;
						}
						dp[n + 1][j][k][l] += dp[n][i][j][k];
						dp[n + 1][j][k][l] %= mod;
					}
				}
			}
		}
	}

	ll res = 0;
	for (int i = 1; i < 5; i++) {
		for (int j = 1; j < 5; j++) {
			for (int k = 1; k < 5; k++) {
				res += dp[N][i][j][k];
				res %= mod;
			}
		}
	}

	out(res);

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

#define NUM 2147483647

int N;
int* table;

void init(int first_N){
	while(N < first_N)N *= 2;
}

void update(int loc,int value){
	loc += N-1;

	table[loc] = value;

	if(N == 1)return;

	int parent = (loc-1)/2;

	while(true){
		table[parent] = min(table[2*parent+1],table[2*parent+2]);

		if(parent == 0)break;
		else{
			parent = (parent-1)/2;
		}
	}
}


int query(int search_left,int search_right,int node_id,int node_left,int node_right){

	if(search_right < node_left || search_left > node_right)return NUM;

	if(search_left <= node_left && search_right >= node_right){
		return table[node_id];
	}

	int left_min = query(search_left,search_right,2*node_id+1,node_left,(node_left+node_right)/2);
	int right_min = query(search_left,search_right,2*node_id+2,(node_left+node_right)/2+1,node_right);

	return min(left_min,right_min);
}


int main(){

	int first_N,Q,command,left,right;
	table = new int[1000000];
	N = 1;

	scanf("%d %d",&first_N,&Q);

	init(first_N);

	for(int i = 0; i <= 2*N-2; i++)table[i] = NUM;

	for(int i = 0; i < Q; i++){
		scanf("%d %d %d",&command,&left,&right);

		if(command == 0){
			update(left,right);
		}else{
			printf("%d\n",query(left,right,0,0,N-1));
		}
	}

	return 0;
}


Measured memory_bytes: 3716
import sys
input = sys.stdin.readline


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

h = 10**11+7
b = 10**7+7

H = [1]
for _ in range(N):
    H.append((H[-1]*b)%h)

C = []
D = []
for i in range(N):
    C.append(A[i-1]^A[i])
    D.append(B[i-1]^B[i])


HashA = 0
for i, a in enumerate(C):
    HashA = (HashA + a*H[i]%h) % h

HashB = 0
for i, a in enumerate(D):
    HashB = (HashB + a*H[i]%h) % h

ans = []
for k in range(N):
    if HashA == HashB:
        ans.append(k)
    HashB = (HashB * b) % h
    HashB = (HashB + (1-H[N])*D[-k-1] % h) % h

for k in ans:
    print(k, A[k]^B[0])

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

using namespace std;
  
int main(){

    int n;
    cin >> n;

    string s, t;
    cin >> s >> t;

    for(int i=0; i<n; i++)
        cout << s[i] << t[i];
    cout << "\n";
    
    return 0; 
} 

Measured memory_bytes: 256
H, W = map(int, input().rstrip().split())
s =[list(input().rstrip()) for _ in range(H)]

for i in range(H):
    for j in range(W):
        if s[i][j] =='#':
            flag = 0
            if i-1 >= 0 and s[i-1][j] == '#':
                flag = 1
            if j-1 >= 0 and s[i][j-1] == '#':
                flag = 1
            if j+1 < W and s[i][j+1] == '#':
                flag = 1
            if i+1 < H and s[i+1][j] == '#':
                flag = 1
            if flag == 0:
                print('No')
                exit()
                
print('Yes')

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-4;
bool eq(double a, double b)
{
	return abs(a - b) < Eps;
}

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		double ideal = 10000;
		int ans = 100000000;
		while (n--)
		{
			int i, h, w;
			scanf("%d %d %d", &i, &h, &w);
			double t = abs(w / (h*h*0.0001) - 22);
			if (t < ideal || eq(ideal, t) && i < ans)
			{
				ideal = t;
				ans = i;
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	int n;
	cin >> n;
	long long a[n];

	int mini;
	long long minv;
	int maxi;
	long long maxv;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i == 0) {
			mini = i;
			minv = a[i];
			maxi = i;
			maxv = a[i];
		} else {
			if (minv > a[i]) {
				minv = a[i];
				mini = i;
			}
			if (maxv < a[i]) {
				maxv = a[i];
				maxi = i;
			}
		}
	}
	vector<pair<int, int>> ans;
	bool plus = true;
	if (minv < 0)
		plus = false;

	if ((minv * maxv) < 0) {
		if (abs(minv) > abs(maxv)) {
			for (int i = 0; i < n; i++) {
				if (a[i] > 0) {
					a[i] += minv;
					ans.push_back(make_pair(mini+1, i+1));
				}
			}
			plus = false;
		} else {
			for (int i = 0; i < n; i++) {
				if (a[i] < 0) {
					a[i] += maxv;
					ans.push_back(make_pair(maxi+1, i+1));
				}
			}
			plus = true;
		}
	}

	if (plus) {
		for (int i = 0; i < n-1; i++) {
			if (a[i] > a[i+1]) {
				a[i+1] += a[i];
				ans.push_back(make_pair(i+1, i+1+1));
			}
		}
	} else {
		for (int i = n-1; i > 0; i--) {
			if (a[i-1] > a[i]) {
				a[i-1] += a[i];
				ans.push_back(make_pair(i+1, i-1+1));
			}
		}
	}

	cout << ans.size() << endl;
	for (auto e : ans) {
		printf("%d %d\n", e.first, e.second);
	}
	return 0;
}

Measured memory_bytes: 3708
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
int h, w, ans = 0;
bool c[1400][1400];//?±????????????????
int r[1400][1400];//?´????WA
int dp[1400][1400];//(i,j)??????????????????????????£?????¢????????§?????????
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			cin >> c[i][j];
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			r[i][j] = (i == 0 ? 0 : r[i - 1][j]) + (j == 0 ? 0 : r[i][j - 1]) + (c[i][j] ? 1 : 0) - (i != 0 && j != 0 ? r[i - 1][j - 1] : 0);
	for (int i = 0; i < h; i++)
		if (!c[i][0])
			dp[i][0] = 1, ans = 1;
	for (int i = 0; i < w; i++)
		if (!c[0][i])
			dp[0][i] = 1, ans = 1;
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			if (!c[i][j]) {
				dp[i][j] = min(dp[i - 1][j], min(dp[i - 1][j - 1], dp[i][j - 1])) + 1;
			}
			ans = max(ans, dp[i][j]);
		}
	}
	cout << ans*ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 31004
#include <iostream>
using namespace std;
int main(void){
    int n , x , d , l , count;
    l = 0;
    d = 0;
    count = 1;
    cin >> n >> x;
    
    for (int i = 1; i <= n; i++) {
       cin >> l;
       d = d + l;
       if (d <= x) {
           count++;
       }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

Y //= 1000

noguti = N

y_n = Y - N

if (Y - N < 0):
    print(-1, -1, -1)
elif (Y - N == 0):
    print(0, 0, N)
else:
    yukiti = y_n // 9
    higuti = y_n // 4
    while True:
        if (yukiti < 0):
            print(-1, -1, -1)
            exit()

        if (yukiti + higuti > N):
            higuti -= 1
            continue

        if(9 * yukiti + 4 * higuti == y_n):
            print(yukiti, higuti, N - yukiti - higuti)
            exit()

        if (9 * yukiti + 4 * higuti > y_n and yukiti >= 0):
            higuti -= 1
            if (higuti < 0):
                yukiti -= 1
                higuti = y_n // 4

        elif (9 * yukiti + 4 * higuti < y_n):
            yukiti -= 1
            higuti = y_n // 4


Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int H, W;

  std::cin >> H >> W;

  std::vector<std::string> a(H);

  for (auto& s : a)
    std::cin >> s;

  int dp[1111][1111];

  memset(dp, 0, sizeof(dp));

  dp[0][0] = 1;

  for (int i = 0; i < H; i ++)
    for (int j = 0; j < W; j ++)
      if (dp[i][j]) {
        int ii, jj;
        
        if ((ii = i + 1) < H)
          if (a[ii][j] != '#')
            (dp[ii][j] += dp[i][j]) %= MOD;

        if ((jj = j + 1) < W)
          if (a[i][jj] != '#')
            (dp[i][jj] += dp[i][j]) %= MOD;
      }

  std::cout << dp[H - 1][W - 1] << std::endl;
  
  return 0;
}


Measured memory_bytes: 6144
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority queue
#include<deque>//double_ended queue
using namespace std;
int main()
{ 
    int n;
    cin>>n;
    for(int i=1;i<10;i++){
        for(int j=1;j<10;j++){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

int main()
{
  char s[81];

  while(gets(s) != NULL){

    int len = strlen(s);
    
    if(strstr(s,"this") || strstr(s,"that") || strstr(s,"the")){
      cout << s << endl;
      continue;
    }
    
    for(int i = 0;i < 'z' - 'a';i++){
      for(int j = 0;j < len;j++){
	if(s[j] >= 'a' && s[j] <= 'z'){
	  if(s[j]+1 > 'z'){
	    s[j] = 'a';
	  }
	  else{
	    s[j]++; 
	  }
	}
      }
      if(strstr(s,"this") || strstr(s,"that") || strstr(s,"the")){
	cout << s << endl;
	break;
      }
    }
  }
}

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

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

class SumSegTree {
private:

	int _sum(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return 0;    // 交差しない
		if (a <= l && r <= b)return dat[k];   // a,l,r,bの順で完全に含まれる
		else {
			int s1 = _sum(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
			int s2 = _sum(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
			return s1 + s2;
		}
	}
public:
	int n, height;
	vector<int> dat;

	// 初期化（_nは最大要素数）
	SumSegTree(int _n) {
		n = 1;
		height = 1;
		while (n < _n) {
			n *= 2;
			height++;
		}
		dat = vector<int>(2 * n - 1, 0);
	}

	// 場所i(0-indexed)にxを足す
	void add(int i, int x) {
		i += n - 1; // i番目の葉ノードへ
		dat[i] += x;
		while (i > 0) { // 下から上がっていく
			i = (i - 1) / 2;
			dat[i] += x;
		}
	}

	// 区間[a,b)の総和。ノードk=[l,r)に着目している。
	int sum(int a, int b) {
		return _sum(a, b, 0, 0, n);
	}
};

void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
	d.resize(G.size());
	REP(i, d.size())d[i] = INF;
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push(make_pair(0, s));
	while (!q.empty()) {
		P a = q.top();
		q.pop();
		if (d[a.second] < a.first)continue;
		REP(i, G[a.second].size()) {
			Edge e = G[a.second][i];
			if (d[e.to] > d[a.second] + e.cap) {
				d[e.to] = d[a.second] + e.cap;
				q.push(make_pair(d[e.to], e.to));
			}
		}
	}
}

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

	ll k;
	cin >> k;
	
	ll n = 50;

	Array ans(n, n - 1+k/n);


	for (int i = 0; i < k % n; i++) {
		ans[i] ++;
	}
	for (int i = k % n; i < n; i++) {
		ans[i] -= k% n;
	}
	cout << ans.size()<<endl;
	for (auto i : ans) {
		cout << i << " ";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

int main() {
  int n, result = 0;
  cin >> n;
  vector<int> p(n);
  REP(i, n) {
    cin >> p[i];
  }
  FOR(i, 1, n-1) {
    if (p[i-1] <= p[i] && p[i] <= p[i+1]) {
      result++;
    } else if (p[i+1] <= p[i] && p[i] <= p[i-1]) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N, M;
    map<string, int> mp;

    cin >> N;
    for(int i = 0; i < N; i++)
    {
        string s;
        cin >> s;
        mp[s]++;
    }

    cin >> M;
    for(int i = 0; i < M; i++)
    {
        string s;
        cin >> s;
        mp[s]--;
    }
    int score = 0;
    for(auto m: mp)
    {
       score = max(score, m.second); 
    }
    cout << score <<endl;

    return 0; 
}


Measured memory_bytes: 256
#include<stdio.h>

#include <stdlib.h>
int main(){
  int j,a[100000][3],n,i,ndnm,parent[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    parent[i]=-1;
    a[i][2]=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d",&ndnm);
    scanf("%d %d",&a[ndnm][0],&a[ndnm][1]);
    if(a[ndnm][0] != -1)
     parent[a[ndnm][0]]=ndnm;
    if(a[ndnm][1] != -1)
     parent[a[ndnm][1]]=ndnm;
  }
  int ins,count=0;
  for(i=0;i<n;i++){
    if(a[i][0]==-1 && a[i][1]==-1){
      
      ins=i;
      while(ins!=-1){
	if(count > a[ins][2])
	  a[ins][2]=count;
	ins=parent[ins];
	count++;
      }
      count=0;


    }
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,parent[i]);
    if(parent[i] == -1)
      printf("sibling = -1, ");
    else if(a[parent[i]][0] == i)
      printf("sibling = %d, ",a[parent[i]][1]);
    else
      printf("sibling = %d, ",a[parent[i]][0]);
      
    ins=parent[i];
    while(ins!=-1){
      ins=parent[ins];
      count++;
    }
    ins=0;
    for(j=0;j<2;j++)
      if(a[i][j]!=-1)
	ins++;
    printf("degree = %d, ",ins);
    printf("depth = %d, ",count);
    printf("height = %d, ",a[i][2]);
    count=0;
    if(parent[i]==-1){
      printf("root");
    }else if(a[i][0]==-1 && a[i][1]==-1){
      printf("leaf");
    }else{
      printf("internal node");
    }
    printf("\n");
    /*
    printf("[");
    for(j=0;a[i][j]!=-1;j++){
      printf("%d",a[i][j]);
    if(a[i][j+1]!=-1)
      printf(", ");
    }
    printf("]\n");
    */ 
  }
}



Measured memory_bytes: 2124
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
#define M 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
const int inf = (int)1e9;

ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}
 
 
unsigned long long popcount(unsigned long long x) {
  x = ((x & 0xaaaaaaaaaaaaaaaaUL) >> 1) +
      (x & 0x5555555555555555UL);
  x = ((x & 0xccccccccccccccccUL) >> 2) +
      (x & 0x3333333333333333UL);
  x = ((x & 0xf0f0f0f0f0f0f0f0UL) >> 4) +
      (x & 0x0f0f0f0f0f0f0f0fUL);
  x = ((x & 0xff00ff00ff00ff00UL) >> 8) +
      (x & 0x00ff00ff00ff00ffUL);
  x = ((x & 0xffff0000ffff0000UL) >> 16) +
      (x & 0x0000ffff0000ffffUL);
  x = ((x & 0xffffffff00000000UL) >> 32) +
      (x & 0x00000000ffffffffUL);
  return x;
}

ll sum1[200010];
ll sum2[200010];
ll digit1[200010][2];
ll digit2[200010][2];

int main(void){
	ll n;
	string s;
	cin>>n>>s;
	ll num = 0;
	for(ll i=0;i<n;i++){
		if(s[i]=='1')num++;
	}
	string x = s;
	reverse(x.begin(),x.end());
	//ll tmp = 0;
	ll tmp1 = 1LL;
	ll tmp2 = 1LL;
	for(int i=0;i<n;i++){
		digit1[i+1][1]=tmp1%(num+1);
		if(num>1)digit2[i+1][1]=tmp2%(num-1);
		tmp1=(tmp1*2LL)%(num+1);
		if(num>1)tmp2 =(tmp2*2LL)%(num-1);
	}
	for(int i=0;i<n;i++){
		sum1[i+1]=(sum1[i]+digit1[i+1][x[i]-'0'])%(num+1);
		if(num>1)sum2[i+1]=(sum2[i]+digit2[i+1][x[i]-'0'])%(num-1);
	}
	//cout<<sum1[n]<<" "<<sum2[n]<<endl;
	for(ll i=0;i<n;i++){
		ll div = num;
		ll tmp=0;
		if(s[i]=='1')div--;
		else div++;
		//cout<<s[i]<<" ";
		if(div==0){
			cout<<0<<endl;
			continue;
		}
		if(div==1){
			cout<<1<<endl;
			continue;
		}
		if(div==num+1){
			tmp = (sum1[n]+digit1[n-i][1])%(div);
			ll ans = 1;
			if(tmp==0){
				cout<<ans<<endl;
				continue;
			}
			while(true){
				ll t = popcount(tmp);
				if(tmp%t==0){
					cout<<ans+1<<endl;
					break;
				}
				else{
					tmp = tmp%t;
					ans++;
				}
			}
			continue;
		}
		if(div==num-1){
			tmp = (sum2[n]-digit2[n-i][1]+div)%(div);
			//cout<<tmp<<" ";
			tmp = (tmp+div)%(div);
			ll ans = 1;
			if(tmp==0){
				cout<<ans<<endl;
				continue;
			}
			while(true){
				ll t = popcount(tmp);
				if(tmp%t==0){
					cout<<ans+1<<endl;
					break;
				}
				else{
					ans++;
					tmp = tmp%t;
				}
			}
			continue;
		}
	}
    return 0;
}

Measured memory_bytes: 13136
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



int main()
{
	int N, K;
	cin >> N >> K;

	vector<ll> H(N);
	rep(i, N) cin >> H[i];

	sort(all(H), greater<ll>());


	ll sum = 0;
	repl(i, K, N) sum += H[i];

	cout << sum << endl;
	
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

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

  int n, m, k; cin >> n >> m >> k;
  vector<string> a(n);
  cin.get();
  for (int i = 0; i < n; ++i) {
    getline(cin, a[i]);
  }
  vector<vector<int>> ans(n, vector<int>(m));
  int cnt_str = 0;
  int to_solve = -1;
  bool found_str = false;
  for (int i = 0; i < n; ++i) {
    bool str = false;
    for (int j = 0; j < m; ++j) {
      str |= a[i][j] == '#'; 
    }
    if (!str) {
      if (!found_str) {
        to_solve = i;
        continue;
      }
      for (int j = 0; j < m; ++j) {
        ans[i][j] = ans[i - 1][j];
      }
    } else {
      found_str = true;
      int j = 0;
      while (j < m && a[i][j] == '.') ++j;
      while (j < m) {
        ++cnt_str;
        for (int k = j; k >= 0 && ans[i][k] == 0; --k) {
          ans[i][k] = cnt_str;
        }
        ++j;
        while (j < m && a[i][j] == '.') ++j;
        if (j == m) {
          for (int k = j - 1; k >= 0 && ans[i][k] == 0; --k) {
            ans[i][k] = cnt_str;
          }
        }
      }
    }
  }
  for (int i = to_solve; i >= 0; --i) {
    ans[i] = ans[i + 1];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }

  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

int gcd(int a, int b);
int lcm(int a, int b);

void solve_A(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);

    if(a[0] == a[1] && a[1] != a[2]) cout << "Yes";
    else if(a[0] != a[1] && a[1] == a[2]) cout << "Yes";
    else cout << "No";
}

void solve_B(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];

    bool flag = true;
    REP(i,n){
        if(a[i] %2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0) flag = false;
        }
    }

    if(flag) cout << "APPROVED";
    else cout << "DENIED";
}

int main(void){
    solve_B();
    
    return 0;
}

int gcd(int a, int b){
    if(a < b) swap(a, b);

    int r = a % b;
    while(r != 0){
        a = b;  b = r;  r = a % b;
    }
    return b;
}

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

Measured memory_bytes: 256
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,k,ans=0,i;
  cin >> n >> k;
  for(i=k; i<=n+1; i++) {
    ans+=n*(n+1)/2-(n-i)*(n-i+1)/2-(i-1)*i/2+1;
    ans%=MOD;
  }
  cout << ans << endl;
}

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

int main() {
int X,Y;
  cin >> X >> Y;
  int count = 0;
  int a;
  for(int i = 0; i <= X; i++){
  	a = 2*i + 4 * (X-i);
    if(a == Y){
    	count++;
    }
  }
  if(count == 0){
  	cout << "No" << endl;
  }
  else cout << "Yes" << endl;
}

Measured memory_bytes: 3636