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

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int x;
  cin >> x;
  cout << (x >= 30 ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3640
#include<iostream>
#include <vector>
#include <map>
#define int long long
#define pb push_back
using namespace std;
const int mxn=1e7;
vector<int> v;
int n,k,ans=1;
map<int,int> m;
int Pow(int x,int y){
	int sum=1;
	while (y) {
		if (y%2) ans*=x;
		x*=x;
		y/=2;
	}
	return sum;
}
signed main () {
	cin>>n>>k;
	int s=k;
	for (int i=2;i<=sqrt(k);i++) {
		if (s%i==0) v.pb(i);
		while (s%i==0) {
			m[i]++;s/=i;
		}
		m[i]/=n;
	}
	if (s!=1) {
		v.pb(s);
		m[s]++;m[s]/=n;
	}
	for (int i=0;i<v.size();i++) {
		if (m[v[i]]!=0) ans*=Pow(v[i],m[v[i]]);
	}
	cout<<ans;
}

Measured memory_bytes: 65688
import sys
for line in sys.stdin:
    arrA,arrB = [],[]
    s = line.split()
    for i in s:
        arrA.append(int(i))
    s = input().split()
    for i in s:
        arrB.append(int(i))
    h,b = 0,0
    for i in range(len(arrA)):
        if arrA[i] == arrB[i]:
            h += 1
        elif arrB.count(arrA[i]) > 0:
                b += 1
    print(h,b)

Measured memory_bytes: 7548
import Data.List.Split

main = do
  hw <- getTwoNum
  case hw of
    (0,0) -> return ()
    (h,w) -> do 
	  mapM_ putStrLn $ createScreen h w
	  putStrLn ""
	  main

createScreen :: Int -> Int -> [String]
createScreen h w = map create_ [1..h]
  where 
    create_ h'
      | h' == 1   = replicate w '#'
      | h' == h   = replicate w '#'
	  | otherwise = '#' : replicate (w-2) '.' ++ "#"

getTwoNum :: IO ((Int,Int))
getTwoNum = do
  (a:b:_) <- getNums
  return (a,b)

getNums :: IO ([Int])
getNums = do
  s <- getLine
  return $ map read $ splitOn " " s


Measured memory_bytes: 3932
/* 159 */
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n,m,ans=0;
    cin>>n>>m;
    if(n>1) ans += (n*(n-1))/2; 
    if(m>1) ans += (m*(m-1))/2;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int selectionSort(int A[], int N){
    int i, j, t, sw = 0, minj;
    for(i = 0; i < N-1; i++){
        minj = i;
        for(j = i; j < N; j++){
            if(A[j] < A[minj])
                  minj = j;
        }
        t = A[i]; A[i] = A[minj]; A[minj] = t;
        if(i != minj)
          sw++;
    }
    return sw;

}

int main(){

     int A[100], N, i, sw;

     scanf("%d", &N);
     for(i = 0; i < N; i++)
       scanf("%d", &A[i]);

     sw = selectionSort(A,N);

     for(i = 0;i < N; i++){
         if(i > 0) printf(" ");
           printf("%d", A[i]);
     }
     printf("\n");
     printf("%d\n",sw);


return 0;

}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
  int H, W;
  cin >> H >> W;
  string S[H];
  vector<vector<int> > vert(H, vector<int>(W));
  vector<vector<int> > hori(H, vector<int>(W));

  REP(i, H) cin >> S[i];

  REP(i, H) {
    int cnt = 0, start = 0;
    REP(j, W) {
      if (S[i][j] == '.') cnt++;
      if (S[i][j] == '#') {
        REP2(k, start, j) hori[i][k] = cnt;
        cnt = 0;
        start = j;
      }
      if (j == W - 1) REP2(k, start, j + 1) hori[i][k] = cnt;
    }
  }

  REP(j, W) {
    int cnt = 0, start = 0;
    REP(i, H) {
      if (S[i][j] == '.') cnt++;
      if (S[i][j] == '#') {
        REP2(k, start, i) vert[k][j] = cnt;
        cnt = 0;
        start = i;
      }
      if (i == H - 1) REP2(k, start, i + 1) vert[k][j] = cnt;
    }
  }

  vector<vector<int> > ans(H, vector<int>(W));
  int answer = 0;
  REP(i, H) {
    REP(j, W) {
      if (S[i][j] != '#') {
        ans[i][j] = vert[i][j] + hori[i][j];
        answer = max(answer, ans[i][j]);
      }
    }
  }

  cout << answer - 1 << endl;
  return 0;
}


Measured memory_bytes: 51456
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
int k,x;
cin>>k>>x;
int z=(x-k)+1;
for(int i=0 ; i<k-1;i++){
    cout<<z<<" ";
    z+=1;
}
cout<<x<<" ";
for(int i=0 ; i<k-1;i++){
    z+=1;
    cout<<z<<" ";

}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#define lli long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define loop(i, j, n) for(int i=j; i<n; i++)
using namespace std;
using Graph = vector<vector<int>>;
int main()
{
	int r, g, n, cnt=0;
	double b, z;
	cin >> r >> g >> b >> n;

	rep(x,3001){
		rep(y,3001){
			z = (n-r*x-g*y)/b;
			if(z == (int)z && (z >= 0 && z <= 3000)){
				cnt++;
			}
		}
	}
	cout << cnt <<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
int main(){
  int N;
  cin >> N;
  vector<P> vec(N);
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    P p = {a,b};
    vec[i] = p;
  }
  
  if(N %2 == 1){
    sort(vec.begin(),vec.end());
    int left = vec[N/2].first;
    for(int i=0; i<N; i++){
      swap(vec[i].first, vec[i].second);
    }
    sort(vec.begin(),vec.end());
    int right = vec[N/2].first;
    cout << right - left + 1 << endl;
  }
  else{
    sort(vec.begin(),vec.end());
    int left1 = vec[N/2-1].first; //小さい
    int left2 = vec[N/2].first; //大きい
    for(int i=0; i<N; i++){
      swap(vec[i].first, vec[i].second);
    }
    sort(vec.begin(),vec.end());
    int right1 = vec[N/2-1].first; //小さい
    int right2 = vec[N/2].first; //大きい
    bool left_p = false;
    bool right_p = false;
    if((left2 - left1) %2 == 1){
      left_p = true;
    }
    if((right2 - right1) %2 == 1){
      right_p = true;
    }
    int left = (left1 + left2)/2;
    if(left_p){
      left++;
    }
    int right = (right1 + right2)/2;
    int64_t ans = (right - left)*2 + 1;
    if(left_p){
      ans++;
    }
    if(right_p){
      ans++;
    }
    cout << ans << endl;
  }
    
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;

string s;


int main()
{
    cin >> s;
    int a = 0;
    for(auto c:s){
        if(c == 'o'){
            a++;
        }
    }
    cout << 700 + 100*a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    int K;
    cin >> K >> S;
    
    if(S.size()>K){
        for(int i=0;i<K;i++){
            cout<<S[i];
        }
        cout << "..." << endl;
    }else{
        cout << S << endl;
    }
    
    return 0;
}


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

int a, b, x;
 
signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> a >> b >> x;
    if (a==0) cout << b/x+1 << endl;
    else cout << b/x-(a-1)/x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll findlcm(ll arr[], ll n)
{
    // Initialize result
    ll ans = arr[0];

    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main()
{
     ll n,i,j,cnt=0,k,w=-100,b,h,m,hcf,prod,t;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
    cin>>n>>m;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=n-1;i>=0;i--)
    {
        if(m!=0)
        {
            m--;
            continue;
        }
        else{
            cnt+=a[i];
        }
    }
    cout<<cnt;
   
   
   
    

	    return 0;
}


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

int main() {
    long long int s, x;
    cin >> s;
    x = (1000000000-s%1000000000)%1000000000;
    cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " " << x << " " << (s+x)/1000000000 << "\n";
    return 0;
}


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

int grad(long long v1, long long v2){
    if(v1 == v2){
        return 0;
    }
    if(v1 < v2){
        return 1;
    }
    if(v1 > v2){
        return -1;
    }
}

int main(){

    int n;
    cin >> n;

    vector<long long>v(n);
     
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }

    int ans = 1;
    int g ;
    for(int i = 1; i < n - 1; i++){
        if(g == 0){
            g = grad(v[i-1], v[i]); 
        }
        int g2 = grad(v[i], v[i+1]);

        if(g * g2 == -1){
            ans ++;
            i ++;
            g = 0;
        }

    }
    
    cout << ans << endl;


}

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

typedef long long ll;
const int MOD = 1e9 + 7;
typedef vector<ll> vll;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    vector<vector<ll>> dp(n + 1, vector<ll>(4));
    dp[0][0] = 1;
    dp[0][1] = dp[0][2] = dp[0][3] = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == '?')
            dp[i + 1][0] = 3 * dp[i][0] % MOD;
        else dp[i + 1][0] = dp[i][0];
        if (s[i] == '?') {
            for (int j = 1; j <= 3; ++j) {
                dp[i + 1][j] = 3 * dp[i][j] % MOD;
            }
        } else {
            for (int j = 1; j <= 3; ++j) {
                dp[i + 1][j] = dp[i][j];
            }
        }
        if (s[i] == 'A') {
            dp[i + 1][1] += dp[i][0];
            dp[i + 1][1] %= MOD;
        } else if (s[i] == 'B') {
            dp[i + 1][2] += dp[i][1];
            dp[i + 1][2] %= MOD;
        } else if (s[i] == 'C') {
            dp[i + 1][3] += dp[i][2];
            dp[i + 1][3] %= MOD;
        } else if (s[i] == '?') {
            dp[i + 1][1] += dp[i][0];
            dp[i + 1][1] %= MOD;
            dp[i + 1][2] += dp[i][1];
            dp[i + 1][2] %= MOD;
            dp[i + 1][3] += dp[i][2];
            dp[i + 1][3] %= MOD;
        }
    }
    cout << dp[n][3] << endl;
    return 0;
}

Measured memory_bytes: 7424
#include <iostream>

int main() {
  long n, m, l, nm[100][100], ml[100][100], c[100][100] = {};
  std::cin >> n >> m >> l;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      std::cin >> nm[i][j];
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < l; j++) {
      std::cin >> ml[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < l; k++) {
        c[i][k] += nm[i][j] * ml[j][k];
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      std::cout << (j == 0 ? "" : " ") << c[i][j];
    }
    std::cout << "\n";
  }
  return 0;
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b, c, x, y;
ll ans = INF;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> a >> b >> c >> x >> y;
    rep(r, 0, 200001) {
        ll p = x - r / 2, q = y - r / 2;
        if (p < 0) p = 0;
        if (q < 0) q = 0;
        ans = min(ans, p * a + q * b + r * c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var answer = false;
            var cake = 0;
            while (n - 4 * cake >= 0)
            {
                var mod = n - 4 * cake;
                if (mod % 7 == 0)
                {
                    answer = true;
                    break;
                }
                cake++;
            }
            Console.WriteLine(answer ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 11092
(let ((N (read)) (K (read)) (Q (read)))
  (setf test (make-array N :initial-element (- K Q)))
  (dotimes (x Q)
    (let ((Ai-1 (1- (read))))
      (setf (aref test Ai-1) (1+ (aref test Ai-1)))
      )

    )
  )

(map nil #'(lambda (x)
	     (princ (if (> x 0) "Yes" "No"))
	     (princ #\newline))
     test)

Measured memory_bytes: 58216
#include<bits/stdc++.h>
using namespace std;
#define ll         long long int
#define co         cout
#define ci         cin
#define sf1(n)     scanf("%lld",&n)
#define sf2(n,m)   scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define pf1(n)     printf("%lld\n",n);
#define mem(a,b)   memset(a,b,sizeof(a))
#define en         cout<<endl;
#define pb         push_back
#define fi         first
#define se         second
#define coy        cout<< "YES"<<endl;
#define con        cout<< "NO"<<endl;
#define f(a,b)     for(ll i=a;i<b;i++)
#define all(x)     (x).begin(),(x).end()
#define allr(x)    (x).rbegin(),(x).rend()
#define pi         pair<ll,ll>
#define br         break;
#define i64        long long
#define PI 3.1415926535897932384626433832795

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,c,res,c1,x,y,w,z,c2;
    string a,b;
    ci>>a>>b;
    c=0;
    f(0,a.size())
    {
        if(a[i]!=b[i]) c++;
    }
    co<<c;
}



Measured memory_bytes: 3832
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N,i;
    cin >> N;
    vector<int> a(N);
    for(i=0;i<N;i++)cin >> a.at(i);
    sort(a.begin(),a.end());
    cout << a.at(N-1) - a.at(0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;


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

char board[1111][1111];
int csum[1111][1111][3];

int g(char c){
	if(c=='J')return 0;
	if(c=='O')return 1;
	return 2;
}

int main(){
	int w,h,qc;
	cin>>h>>w>>qc;
	
	rep(i,h){
		scanf("%s",&board[i]);
	}
	
	reps(i,1,h+1){
		reps(j,1,w+1){
			rep(k,3){
				csum[i][j][k] += csum[i][j-1][k];
				csum[i][j][k] += csum[i-1][j][k];
				csum[i][j][k] -= csum[i-1][j-1][k];
			}
			char c = board[i-1][j-1];
			csum[i][j][g(c)]++;
		}
	}
	
	rep(i,qc){
		int xst,yst,xen,yen;
		scanf("%d%d%d%d",&xst,&yst,&xen,&yen);
		
		rep(k,3){
			int ans=0;
			ans += csum[xen][yen][k];
			ans -= csum[xst-1][yen][k];
			ans -= csum[xen][yst-1][k];
			ans += csum[xst-1][yst-1][k];
			printf("%d",ans);
			if(k!=2)printf(" ");
		}puts("");
	}
}

Measured memory_bytes: 16636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AStationAndBus solver = new AStationAndBus();
        solver.solve(1, in, out);
        out.close();
    }

    static class AStationAndBus {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            if (s.contains("A") && s.contains("B")) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }
}



Measured memory_bytes: 20692
#include "bits/stdc++.h"
#define rep(i, j) for (long long i = j; i > 0; i--)
using namespace std;

int main() {
	string s;
	string t;
	cin >> s;
	cin >> t;
	int flag = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			flag = 1;
			break;
		}
	}
	if (flag == 0 && s.size() == t.size() - 1)
		cout << "Yes" << endl;
	else
	    cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", ";
        a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


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


    for (;;) {
        int N, L; cin >> N >> L;
        if (N == 0) break;

        vector<char> D(N);
        vi P(N);
        int ma = 0, maxId = -1;
        REP(i, N) {
            cin >> D[i] >> P[i];
            if (D[i] == 'L') {
                if (ma <= P[i]) {
                    ma = P[i];
                    maxId = i;
                }
            }
            if (D[i] == 'R') {
                if (ma < L - P[i]) {
                    ma = L - P[i];
                    maxId = i;
                }
            }
        }

        vi a(N);
        iota(ALL(a), 0);
        REP(k, ma) {
            REP(i, N) {
                if (D[i] == 'L') --P[i];
                if (D[i] == 'R') ++P[i];
            }
            REP(i, N) {
                FOR(j, i+1, N) {
                    if (P[i] == P[j]) {
                        swap(a[i], a[j]);
                    }
                }
            }
        }

        cout << ma << ' ' << a[maxId] + 1 << endl;
    }


    return 0;
}



Measured memory_bytes: 3172
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;
 
#define MOD 1000000007
#define A first
#define B second
 
typedef long long ll;
 
inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}
 
inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}
 
inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}
 
inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}
 
inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}
 
inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}
 
const int N = 1e5 + 5;

int arr[N];

void solve(){
  int n;
  cin >> n;
  int f = 0;
  for(int i = 0; i < n; i++){
    cin >> arr[i];
  }
  for(int i = 0; i < n; i++){
    if(arr[i] % 2 == 0){
      if(arr[i] % 3 != 0 && arr[i] % 5 != 0){
        f = 1;
        break;
      }
    }
  }
  if(f == 1){
    cout << "DENIED";
  }
  else {
    cout << "APPROVED";
  }

}

int main(){
  int t;
  t = 1;
  //cin >> t;
  while(t--){
    solve();
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;

	V<bool> food(m, true);
	int ans = m;
	rep(i, n) {
		int k;
		cin >> k;
		V<bool> like(m, false);
		while (k--) {
			int aa;
			cin >> aa;
			like[aa - 1] = true;
		}
		rep(j, m)if ((!like[j]) && (food[j])) {
			food[j] = false;
			ans--;
		}
	}
	cout << ans << endl;
}

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

using namespace std;

#define pb			push_back
#define all(v)			((v).begin()), ((v).end())
#define SZ(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define has(c,i) 		((c).find(i) != end(c))
#define hastr(s, c)		((s).find(c) != string::npos)
#define FOR(i,a,b) 		for (int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;

int main() {

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b;

    return 0;
}


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

using namespace std;

int main(void){
    int n, x;
    cin >> n >> x;
    
    vector<int> l(n);
    vector<int> bound(n+1,0);
    
    for (int i = 0; i < n; i++) cin >> l[i];
    for (int i = 1; i <= n; i++) bound[i] = bound[i-1] + l[i-1];
    
    int ans = upper_bound(bound.begin(),bound.end(),x) - bound.begin();
    
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

const int mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n+1);
    rep(i,m){
        int ai;
        cin >> ai;
        a[ai] = 1;
    }
    vector<int> dp(n+1);
    dp[0] = 1;
    for(int i = 0; i <= n; i++){
        if (i+1 <= n && a[i+1] != 1) {
            dp[i+1] += dp[i];
            dp[i+1] %= mod;
        }
        if (i+2 <= n && a[i+2] != 1){
            dp[i+2] += dp[i];
            dp[i+2] %= mod;
        } 
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4032
n = int(input())

sp = {}
for i in range(n):
    s, p = input().split()
    p = int(p)
    if s not in sp.keys():
        sp[s] = [(p, i+1)]
    else:
        sp[s].append((p, i+1))

ss = sorted(list(set(sp.keys())))
for s in ss:
    for p, i in sorted(sp[s], reverse = True):
        print(i)
       


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> alpha(26, 99999);
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;

		vector<int> tmp(26, 0);
		for (char c: s) {
			tmp[c - 'a']++;
		}
		for (int j = 0; j < alpha.size(); j++) {
			alpha[j] = min(alpha[j], tmp[j]);
		}
	}

	string ans;
	for (int i = 0; i < alpha.size(); i++) {
		if (alpha[i] > 0) {
			ans += string(alpha[i], 'a' + i);
		}
	}

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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long Q, H, S, D;
	cin >> Q >> H >> S >> D;

	long long N;
	cin >> N;

	H = min(H, 2 * Q);
	S = min(S, 2 * H);

	cout << (N / 2) * min(S * 2, D) + (N % 2) * S;

	return 0;
}


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

using namespace std;

int n, N, i, j, p, u, k, m;
char t;
string s;

char culoare(int k) {
    cout << "?";
    for (i = k; i < k + n; ++i) {
        cout << ' ' << i;
    }
    cout << "\n";
    cin >> s;
    return s[0];
}

int main() {
    cin >> n;
    N = 2 * n;
    p = 1;
    u = n;
    t = culoare(1);
    while (p <= u) {
        m = (p + u) >> 1;
        if (culoare(m) == t) {
            k = m;
            p = m + 1;
        } else {
            u = m - 1;
        }
    }
    string v(N, '.');
    v[k - 1] = t;
    v[k + n - 1] = (t == 'R' ? 'B' : 'R');
    for (j = k + 1; j < k + n; ++j) {
        cout << "? " << j;
        for (i = 1; i < k; ++i) {
            cout << ' ' << i;
        }
        for (i = k + n + 1; i <= N; ++i) {
            cout << ' ' << i;
        }
        cout << "\n";
        cin >> s;
        v[j - 1] = s[0];
    }
    for (j = 1; j < k; ++j) {
        cout << "? " << j;
        for (i = k + 1; i < k + n; ++i) {
            cout << ' ' << i;
        }
        cout << "\n";
        cin >> s;
        v[j - 1] = s[0];
    }
    for (j = k + n + 1; j <= N; ++j) {
        cout << "? " << j;
        for (i = k + 1; i < k + n; ++i) {
            cout << ' ' << i;
        }
        cout << "\n";
        cin >> s;
        v[j - 1] = s[0];
    }
    cout << "! " << v << "\n";
    return 0;
}


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

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	if(a>=b && a>=c){
		for(int i=0; i<k; i++){
			a+=a;
		}
	}
	else if(c>=b && c>=a){
		for(int i=0; i<k; i++){
			c+=c;
		}
	}
	else{
		for(int i=0; i<k; i++){
			b+=b;
		}
	}
	cout << a+b+c <<endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# coding: utf-8
import sys
# 整数 > 整数型
def I(): return int(input())

# 整数列 '1 2 3 4' > 整数型リスト
def IsIl(): return list(map(lambda x: int(x), input().split()))

# 改行挟む整数列　'1/n 2/n 3/n' > 整数型りすと
def InIl(n): return [input() for i in range(n)]

# 整数列 '1 2' > 整数型タプル
def IsIt(): return map(lambda x: int(x), input().split())

# 改行挟む整数列　'1\n 2\n 3\n' > 整数型たぷる
def InIl(n): return map(input() for i in range(n))

# 文字列 'abcd' > 文字型リスト
def SsSl(): return list(map(lambda x: x, input()))

# 整数 '1234' > 整数型リスト

# 文字列 'aba' > 辞書（文字型:個数）{'a':2,'b':1}
def SSd():
    from collections import defaultdict
    A = input() # [int(i) for i in input().split()]
    dd=defaultdict(int)
    for a in A:
        dd[a]+=1
    return dd

#リストにn個要素を読み込む

# その他アルゴリズムテンプレート
# https://qiita.com/chun1182/items/ddf2b6cba932b2bb0d4e
#from heapq import heappop, headpush
from heapq import heappop, heappush

n = I()

lis_a = IsIl()



q = []
for num, item in enumerate(lis_a):
    heappush(q,(item,num+1))

ans = ''
for num in range(n):
    a, num = heappop(q)
    ans += str(num)+' '


print(ans)


Measured memory_bytes: 18916
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

short board[5001][5001];
int main() {
	int N,M;
	scanf("%d%d",&N,&M);
	for(int i=0;i<M;i++){
		int a,b,x;
		scanf("%d%d%d",&a,&b,&x);
		board[a][b]=max(board[a][b],(short)(x+1));
	}
	int ret=0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=i;j++){
			board[i][j]=max((int)board[i][j],board[i-1][j]-1);
			board[i][j]=max((int)board[i][j],board[i-1][j-1]-1);
			if(board[i][j]){
				ret++;
			}
			//cout << i << ", " << j << ": " << board[i][j] << endl;
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 48880
# AOJ 1043: Selecting Teams Advanced to Regional
# Python3 2018.7.6 bal4u

def pr(i, u):
	global total
	print(team[i][0])
	total, affi[u] = total+1, affi[u]+1

while True:
	n = int(input())
	if n == 0: break
	team = []
	for i in range(n):
		id, u, a, p = map(int, input().split())
		team.append((id, u, a, p))
	team.sort(key=lambda x:(-x[2],x[3],x[0]))
	total, affi = 0, [0]*1002
	for i in range(n):
		u = team[i][1]
		if   total < 10 and affi[u] < 3: pr(i, u)
		elif total < 20 and affi[u] < 2: pr(i, u)
		elif total < 26 and affi[u] < 1: pr(i, u)


Measured memory_bytes: 5620
#include <iostream>
int main()
{
  int n;
  while (std::cin >> n) {
    int r = 0;
    for (int a = 0; a < 10; a++) {
      for (int b = 0; b < 10; b++) {
        for (int c = 0; c < 10; c++) {
          for (int d = 0; d < 10; d++) {
            if (a + b + c + d == n) {
              r++;
            }
          }
        }
      }
    }
    std::cout << r << std::endl;
  }
}

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

using namespace std;

const int N = 100010;
int n, m;
int cnt[N], rd[N];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) cnt[i] = 1;
    rd[0] = 1;
    for (int i = 0; i < m; i++) {
        int x, y;
        scanf("%d %d", &x, &y); x--; y--;
        cnt[x]--;
        cnt[y]++;
        rd[y] |= rd[x];
        if (cnt[x] == 0) rd[x] = 0;
    }
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (rd[i]) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

long lcm(long x, long y){
    if(y == 0)  return x;
    return lcm(y, x%y);
}


int main()
{
    long N, M;
    long a[100005], power2[100005];
    bool flag;
    cin >> N >> M;
    REP(i, N)
        cin >> a[i];
    REP(i, N){
        power2[i] = 0;
        REP(j, 30){
            if(a[i]%2 == 0){
                a[i] /= 2;
                power2[i]++;
            }else
                break;
        }
    }
    //REP(i, N)
    //    cout << a[i] << " " << power2[i] << endl;
    flag = false;
    REP(i, N-1)
        if(power2[0] != power2[i+1])
            flag = true;

    if(flag)
        cout << 0 << endl;
    else
    {
        long gcd;
        if(N==1){
            gcd = a[0];
        }else{
            gcd = a[0] / lcm(a[0], a[1]) * a[1];
            if(gcd > M){
                cout << 0 << endl;
                return 0;
            }
            REP(i, N-2){
                gcd = gcd / lcm(a[i+2], gcd) * a[i+2];
                if(gcd > M){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
        REP(i, power2[0]-1){
            gcd *= 2;
            if(gcd > M){
                cout << 0 << endl;
                return 0;
            }
        }
        
        gcd = M / gcd;
        cout << (gcd+1)/2 << endl;
    }
    return 0;
    
}



Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**6) #再帰関数の上限
import math
from copy import copy, deepcopy
from operator import itemgetter

from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque 
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
#dequeを使うときはpython3を使う、pypyはダメ
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone

def input(): return sys.stdin.readline()[:-1]
def printl(li): print(*li, sep="\n")
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
H, W ,K= map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = list(map(int, input().split()))
S = [list(map(int, list(input()))) for i in range(H)]
rui=[[0]*(W+1) for _ in range(H)]
tate=[False]*(H-1)

for i in range(H):
    for j in range(1,W+1):
        rui[i][j]=rui[i][j-1]+S[i][j-1]

ans=H*W
for tcut in range(2**(H-1)):
    ncut=0
    for h in range(H-1): 
        if tcut >> h &1:
            tate[h]=True
            ncut+=1
        else:
            tate[h]=False
    start=0
    bed=[]
    for h in range(H-1):
        if tate[h]==True:
            goal=h+1
            part=[0]*(W+1)
            for i in range(start,goal):
                for j in range(1,W+1):
                    part[j]+=rui[i][j]
            bed.append(part)
            start=h+1
    goal=H
    part=[0]*(W+1)
    for i in range(start,goal):
        for j in range(1,W+1):
            part[j]+=rui[i][j]
    bed.append(part)
    ycut=0
    pos=True
    for j in range(1,W+1):
        for b in bed:
            if b[j]-b[j-1]>K:
                pos=False
                break
            elif b[j]-b[ycut]>K:
                ycut=j-1
                ncut+=1
        if pos==False:
            break
    if pos==False:
        continue
    ans=min(ans,ncut)    

                
print(ans)
            
#print(rui)

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define MOD 1000000000000000001
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define MAX 1000000

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}
ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a=(a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll>&fact, vector<ll>&factinv)
{
    fact[0] = 1;
    factinv[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
        fact[i] = (fact[i-1] * i)%MOD;
    
    for(ll i = 1; i <= MAX; i++)
        factinv[i] = (factinv[i-1] * fastpower(i, MOD -2) )%MOD;

}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t,n,m,k,q;
    set<ll>s;
    cin>>n;
    k = sqrt(n);
    ll res = 0;
    for(ll i=2;i<=k;i++)
    {
        if(n%i == 0)
        {
            q = 0;
            while(n%i == 0)
            {
                n /= i;
                q++;
            }
            for(ll j=1;;j++)
            {
                if(q >= j)
                {   q -= j;
                    res++;
                }
                else
                    break;
            }

        }
    }
    if(n > 1)
        res++;
    cout<<res;
    return 0;
}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const ll powll = 1LL<<1;

int main(void){
   int n; cin >> n;
   int ans = 0;
   int a[n]; rep(i,0,n) cin >> a[i];
   sort(a,a+n);
   rep(i,0,n){
       if(i%2==0){
           ans+=a[n-1-i];
       }else{
           ans-=a[n-1-i];
       }
   }
   cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1 % mod;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll h, w;
  cin >> h >> w;

  if (w == 1 or h==1) {
    cout << 1 << en;
    return 0;
  }

  ll h1 = (h + 1) / 2;
  ll h2 = h - h1;
  ll w1 = (w + 1) / 2;
  ll w2 = w - w1;

  cout << h1 * w1 + h2 * w2 << en;

  return 0;
}


Measured memory_bytes: 256
def solve():
    N,K = [int(i) for i in input().split()]
    ans = 0
    mod = 10**9 + 7
    for M in range(K, N+2):
        min_sum = (M-1) * M // 2
        max_sum = (2*N-(M-1)) * M // 2
        cnt = max_sum - min_sum + 1
        ans += cnt
        ans %= mod
    print(ans)

if __name__ == "__main__":
    solve()

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair < pair <int, int> , int> ppi;
typedef pair < pair <int, int> , ll> ppll;
typedef pair <ll, ll> pll;
typedef string str;

# define endl		 '\n'
# define sep		 ' '
# define F 			 first
# define S 			 second
# define pb			 push_back
# define fast_io 	 ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll md = 1e9+7;

ll gcd(ll a, ll b){ if (b == 0) return a; return gcd(b, a%b);}
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b);}
ll pw(ll a, ll b){
	if (b == 1) return (a+md)%md;
	if (b%2 == 0) return (pw(a*a, b/2)+md)%md;
	else return (a*pw(a*a, b/2)+md)%md;
}

const int xn = 1e6+10;
const int xm = 5e4+10;

int cnt[5];

int main(){
	fast_io;
	
	int a, b;
	cin >> a >> b;
	cnt[a]++, cnt[b]++;
	for (int i=1; i<=3; i++){
		if (cnt[i] == 0){
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}
/*
8
23 2 7 5 15 8 4 10
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans = 0;
    rep(i,16) if (s[i] != t[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll H,N;
  cin>>H>>N;
  vector<vector<ll>> AB(N,vector<ll>());
  FOR(i,N){
    ll a,b;
    cin>>a>>b;
    AB[i]=vector<ll>{a,b};
  }
  vector<ll> dp(H+100000,100000000000);
  dp[0]=0;
  FOR(ii,H+60000){
    ll i = ii+1;
    ll min_=100000000000;
    FOR(j,N){
      if(i-AB[j][0]<0)continue;
      ll tmp=dp[i-AB[j][0]]+AB[j][1];
      //cout<<tmp<<endl;;
      if(min_>tmp)min_=tmp;
    }
    //cout<<i<<endl;
    dp[i]=min_;
  }
  ll m = LLONG_MAX;
  FOR(i,50000){
    ll tmp=dp[i+H];
    if(m>tmp)m=tmp;
    //cout<<tmp<<endl;
  }
  cout<<m<<endl;
  return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(max(a,c)-min(b,d)<0)
  cout<<min(b,d)-max(a,c)<<endl;
  else
  cout<<0<<endl;
  }
  
  
  
  
  

  
  

 


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

using namespace std;

int main(void)
{
    int n;
    cin>>n;
    long long int sum = 1,error = 1;

    for(int i = 0;i < n;i++)
    {
        int a;
        cin>>a;
        sum *= 3;
        if(a%2 == 0)
            error *= 2;
    }

    cout<<sum-error<<endl;

    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int dp[61][2][2][2];

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

	long long l, r;
	cin >> l >> r;
	//dp[桁(i)][L(j)][R(k)][最上位(s)]
	dp[60][0][0][0] = 1;
	for (int i = 59; i >= 0; i--) {
		int lb = (l >> i) & 1;
		int rb = (r >> i) & 1;
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k < 2; k++) {
				for (int s = 0; s < 2; s++) {
					for (int x = 0; x < 2; x++) {
						for (int y = 0; y < 2; y++) {
							if (x && !y) continue;
							int nj = j; int nk = k; int ns = s;
							if (!s && x != y) continue;
							if (x && y) ns = 1;
							if (!j && lb && !x) continue;
							if (!lb && x) nj = 1;
							if (!k && !rb && y) continue;
							if (rb && !y) nk = 1;
							dp[i][nj][nk][ns] += dp[i + 1][j][k][s];
							dp[i][nj][nk][ns] %= MOD;
						}
					}
				}
			}
		}
	}
	long long ans = 0;
	for (int j = 0; j < 2; j++) {
		for (int k = 0; k < 2; k++) {
			for (int s = 0; s < 2; s++) {
				ans += dp[0][j][k][s];
				ans %= MOD;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())

L = list(map(int,input().split()))

ans = 0
cur = 0

for i in range(N):
    if i == N-1:
        ans = max(ans, cur)
        continue
    h = L[i]
    nex = L[i+1]
    if h >= nex:
        cur += 1
    else:
        ans = max(ans,cur) 
        cur = 0

print(ans)


Measured memory_bytes: 63856
n = int(input())
li = list(range(n))
lis = list(range(n))
for i in range(n):
    s_i, t_i = map(str, input().split())
    li[i] = s_i
    lis[i] = int(t_i)
x = input()
counter = 0
while x != li[counter]:
    counter = counter+1
    i = counter+1
counter=counter+1
su = 0
while counter != n:
    su = su+lis[counter]
    counter=counter+1
print(su)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define taskname "A"
#define pb push_back
#define mp make_pair
#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 long double ld;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
const int maxn = 2e3 +5;
const int mod =998244353;
const int inf = 1e9 + 1;
const ll llinf = 1e18 + 5;
ii a[maxn];
int n,p[maxn];
ii operator - (ii a , ii b){
    return mp(a.first - b.first , a.second - b.second);
}
bool operator * (ii a , ii b){
    return a.first * b.second - a.second * b.first;
}
ll ccw(ii a , ii b , ii c){
    return (a - b) * (c - b);
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    cin >> n;
    p[0] = 1;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i].first >> a[i].second;
        p[i] = p[i - 1] * 2 % mod;
    }
    int res = (p[n] - 1 - (ll)n * (n + 1) / 2) % mod;
    for(int i = 1 ; i <= n ; ++i){
        for(int j = i + 1 ; j <= n ; ++j){
            int cnt = 0;
            for(int t = j + 1 ; t <= n ; ++t){
                cnt += (ccw(a[i],a[j],a[t]) == 0);
            }
            res = (res - (p[cnt] - 1)) % mod;
        }
    }
    cout << (res + mod) % mod;
}



Measured memory_bytes: 256
WV = $<.read.split.map(&:to_i).each_slice(2).to_a
N,W = WV.shift
WV.sort_by!{|w,v| w>W ? 1<<60 : (v<<30)+w}
I = [0]
tv=tw = 0
i = WV.map!.with_index {|(w,v),i|
  break 0...i  if w > W
  I << I[-1]=[v,i]  if I[-1][0] < v
  tv+=v; tw+=w; w
}.size
I[-1] = [1<<60,i]
A = Array.new(tv+1, [tw,-1])
A[0] = [0,0]
l = tw > W ? 0 : tv
l.upto(tv-1) {|n|
  c,b = A[n]
  l = n if c <= W
  next  if c >= W
  0.upto(I.size-2) {|i|
    j = I[i+1][1]
    next  if b[j-1] > 0
    v,i = I[i]
    next  if WV[i] >= a=A[v+=n][0]-c
    x = b | b+(1<<i)
    w = WV[((x^b)-1).bit_length]
    A[v] = [c+w,x]  if w < a
  }
}
p l

Measured memory_bytes: 9336
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

        int num = Integer.parseInt(br.readLine());

        String[] input = br.readLine().split(" " , num);
        StringBuilder sb = new StringBuilder();

        for(int i = 0; i < num; i++){
            sb.append(input[num-1-i] + " ");
        }

        System.out.println(sb.toString().substring(0 , sb.toString().length()-1));
    }
}

Measured memory_bytes: 24208