akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
char s[300000];
int main() {
    int n, cou = 0, min;
    scanf("%d %s", &n, s);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') {
            cou++;
        }
    }
    min = cou;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'E') cou--;
        if (i != 0 && s[i - 1] == 'W') cou++;
        if (cou < min) min = cou;
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 512
<?php
	$cnt = array_fill_keys( range( 'a', 'z'), 0 );
			
	while( FALSE != ( $data = fgets( STDIN ) ) ) {
		$strs = str_split( strtolower( trim( $data ) ) );
		
		foreach( $strs as $c ) {
			if( ctype_alpha( $c ) ) {
				$cnt[ $c ]++;
			}
		}
	}
	foreach( $cnt as $k => $val ) {
		print $k." : ".$val.PHP_EOL;
	}
	return;
?>

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

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define dump_1(x1) cerr << #x1 << ": " << x1 << endl
#define dump_2(x1, x2) \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define dump_3(x1, x2, x3)                                                \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << endl
#define dump_4(x1, x2, x3, x4)                                            \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << endl
#define dump_5(x1, x2, x3, x4, x5)                                        \
  cerr << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
       << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define dump(...) \
  CHOOSE((__VA_ARGS__, dump_5, dump_4, dump_3, dump_2, dump_1, ~))(__VA_ARGS__)
#define check(s) cerr << s << endl

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

using namespace std;

using ll = long long;

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

void solve(ll N, std::vector<ll> a, std::vector<ll> b, std::vector<ll> c) {
  vector<vector<ll>> dp(N + 1, vector<ll>(3, 0));

  rep(i, N) {
    dp.at(i + 1).at(0) = a.at(i) + max(dp.at(i).at(1), dp.at(i).at(2));
    dp.at(i + 1).at(1) = b.at(i) + max(dp.at(i).at(0), dp.at(i).at(2));
    dp.at(i + 1).at(2) = c.at(i) + max(dp.at(i).at(0), dp.at(i).at(1));
  }

  cout << max(dp.at(N).at(0), max(dp.at(N).at(1), dp.at(N).at(2))) << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  std::vector<ll> a(N);
  std::vector<ll> b(N);
  std::vector<ll> c(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
    scanf("%lld", &c[i]);
  }
  solve(N, std::move(a), std::move(b), std::move(c));
  return 0;
}


Measured memory_bytes: 11180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int n, k;
vector<int> d;

bool f(int v) {
    map<int, int> mi;
    
    
    while(v) {
        mi[v % 10]++;
        v /= 10;
    }
    
    rep(i, k) {
        for (auto u : mi) {
            if ((u.first == d[i]) && (u.second > 0)) {
                return true;
            }
        }
    }
    
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    cin >> n >> k;
    d.resize(k);
    rep(i, k) cin >> d[i];
    int ans = 0;
    
    for (int i = n; ; i++) {
        if (!f(i)) {
            ans = i;
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fn main_() {
    assert_eq!(solve("2 2\n1 2\n3 4\n3 4\n2 1\n"), "0\n");
    assert_eq!(solve("2 3\n1 10 80\n80 10 1\n1 2 3\n4 5 6\n"), "2\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let h: usize = sc.read();
    let w: usize = sc.read();
    let m = 80*(h+w-1)+1;
    let a: Vec<Vec<usize>> = (0..h)
        .map(|_| (0..w).map(|_| sc.read()).collect())
        .collect();
    let b: Vec<Vec<usize>> = (0..h)
        .map(|_| (0..w).map(|_| sc.read()).collect())
        .collect();
    let mut dp = vec![vec![vec![false;m]; w]; h]; 
    
    dp[0][0][dif(a[0][0],b[0][0])] = true;
    for i in 0..h {
      for j in 0..w {
        let p = dif(a[i][j],b[i][j]);
        for d in 0..m {
          if (i>0 && dp[i-1][j][d])||(j>0 && dp[i][j-1][d]) {
            dp[i][j][d+p] = true;
            dp[i][j][dif(d,p)] = true;
          }
        }
      }
    }
    
    for scr in 0..m {
      if dp[h-1][w-1][scr] {
        return format!("{}\n", scr);
      }
    }
    "".to_string()
}

fn dif(a: usize, b: usize) -> usize {
  if a > b {
    a - b
  } else {
    b - a
  }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


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

#define int long long
#define double long double 

using namespace std;

const int INF = 1e+18;
const int MAXN = 100000;
const int LOGN = 20;
const int mod = 1e9+7;



signed main() {
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n, W;
    cin >> n >> W;
    int w[n];
    int v[n];
    for (int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }

    int dp[n + 1][W + 1];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i][j] = 0;
        }
    }

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

Measured memory_bytes: 79232
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

int main(void)
{
  int n,i;
  cin>>n>>i;
  int ans=n+1-i;
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main(void){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << a[K - 1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    for(int i=3;i<=999991;i++){
	bool flg = true;
	for(int j=0;primes[j]*primes[j] <= i;j++){
	    if(i % primes[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg) primes.PB(i);
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int ans = 0;
	for(int i=0;primes[i]<=n/2;i++){
	    int j = lower_bound(ALL(primes),n-primes[i]) - primes.begin();
	    if(primes[j] + primes[i] == n) {
		ans++;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int N;

    cin >> N;

    vector<int> A(N);

    REP(i,N){
        cin >> A[i];
        if(A[i] % 2 == 0){
            if((A[i] % 3 != 0) && (A[i] % 5 != 0)){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

Measured memory_bytes: 256
class Card
  include Comparable
  def initialize(val)
    @val = val
  end

  def mark
    @val[0]
  end

  def number
    @val[1].to_i
  end

  def <=>(other)
    number <=> other.number
  end

  def to_s
    @val.dup
  end
end

def bubble_sort(arr)
  n = arr.size - 1
  0.upto(n) do |i|
    n.downto(i + 1) do |j|
      arr[j-1], arr[j] = arr[j], arr[j-1] if arr[j] < arr[j-1]
    end
  end
end

def selection_sort(arr)
  n = arr.size - 1
  0.upto(n) do |i|
    mini_j = i
    i.upto(n) do |j|
      mini_j = j if arr[j] < arr[mini_j]
    end
    arr[i], arr[mini_j] = arr[mini_j], arr[i]
  end
end

def stable?(cards, sorted)
  orig_order = order_hash(cards)
  sorted_order = order_hash(sorted)
  orig_order.map{|k, v| sorted_order[k] == v}.all?
end

def order_hash(cards)
  order = Hash.new {|h, k| h[k] = ''}
  cards.each{|c| order[c.number] << c.mark }
  order
end


n = gets.to_i
cards = gets.split.map{|v| Card.new(v)}

bubble = cards.dup
selection = cards.dup

bubble_sort(bubble)
puts bubble.join("\s")
puts stable?(cards, bubble) ? 'Stable' : 'Not stable'

selection_sort(selection)
puts selection.join("\s")
puts stable?(cards, selection) ? 'Stable' : 'Not stable'

Measured memory_bytes: 8840
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long N, std::vector<long long> A, std::vector<long long> K){

}

int main(){
    int R,G,B,N;

    cin>>R>>G>>B>>N;
    int ans=0;
    REP(i, N+1){
        REP(j, N+1){
            int kRes = (N- R*i - G*j) % B;
            int k = (N- R*i - G*j) / B;
            if(kRes==0 && k>=0){
                ans++;
                // debug(i);
                // debug(j);
                // debug(k);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n,m,j, a[200600], ans=9999, k;
bool cond;
char c;
string S, T;
int main()
{
    //I am Monim, a tiny creature of Allah
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> S >> T;
    n = S.size();
    m = T.size();
    for(i=0;i<n-m+(n==m);i++)
    {
        k = 0;
        for(j=0;j<m;j++)
        {
            if(i+j<n)
            {
                if(S[i+j]!=T[j])
                    k++;
            }
        }
        ans = min(ans, k);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  	int N, ans;
  	string S;
  	cin >> N >> S;
  	ans = N;
  
  	for(int i=0; i<N-1; i++){
    	if(S[i] == S[i+1]){
        	ans--;
        }
    }
  	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

const int MAXP = 101; 

int n, m;
int X, Y;
int xmax = -MAXP, xmin = MAXP, ymax = -MAXP, ymin = MAXP;

void swap(int &x, int &y) {
    int tmp = x;
    x = y;
    y = tmp; 
} 

int main() {
    cin >> n >> m >> X >> Y;
    xmax = xmin = X;
    ymax = ymin = Y;
    for (int i = 0;i < n;i ++) {
        int x;
        cin >> x;
        xmax = xmax < x ? x : xmax;
        xmin = xmin > x ? x : xmin;
    }
    for (int i = 0;i < n;i ++) {
        int y;
        cin >> y;
        ymax = ymax < y ? y : ymax;
        ymin = ymin > y ? y : ymin;
    }
    if (xmax < ymin || ymax < xmin) cout << "No War" << endl;
    else cout << "War" << endl;
    return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10,inf=0x3f3f3f3f,mod=1e9+7;
char s[maxn];
inline int ksm(int x,int y){
	int res=1;
	while(y){
		if(y&1) res=(ll)res*x%mod;
		y>>=1;
		x=(ll)x*x%mod;
	}
	return res;
}
int dp[maxn],sum[maxn];
int main(){
	int n=read(),m=read();
	scanf("%s",s+1);
	int Min=inf;
	for(int i=1,j;i<=m;i++) if(s[i]==s[1]){
		j=i;
		while(j<m && s[j+1]==s[1]) ++j;
		if(j!=m){
			if((j-i+1)%2==1) chkmin(Min,j-i+1);
			else if(i==1) chkmin(Min,j-i+2);
		}
		i=j;
	}
	int flag=1;
	REP(i,2,m) flag&=(s[i]==s[1]);
	dp[1]=sum[1]=1;
	REP(i,2,n+1){
		if(flag){
			dp[i]=sum[i-2];
			sum[i]=(sum[i-1]+dp[i])%mod;
		}
		else{
			dp[i]=(sum[i-2]-sum[max(i-Min-3,0)]+mod)%mod;
			sum[i]=(sum[i-2]+dp[i])%mod;
		}
	}
	int ans=(dp[n+1]*2+flag)%mod;
	REP(i,1,n-2) if(((n-i)%2==1 && n-i<=Min) || flag) ans=(ans+(ll)dp[i]*(n-i-1))%mod;
	printf("%d\n",ans);
	return 0;
}


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

const int N = 100005;
int n, a[N];

int main() {
    scanf("%d", &n);
    long long result = 0;
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
        if (a[i] > 0) {
            sum += a[i];
        } else {
            result += sum / 2;
            sum = 0;
        }
    }
    result += sum / 2;
    cout << result << endl;
    return 0;
}


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

const long long MOD = 998244353;

class Math {
public:
    Math(int N = 0, long long mod = 1e9 + 7)
        : N_(N)
        , mod_(mod)
    {
    }

    long long pow(long long x, long long y)
    {
        return powm(x, y, mod_);
    }

    long long combination(long long n, long long k)
    {
        if (k < 0 || k > n) {
            return 0;
        }
        if (fact_.empty()) {
            build_fact();
        }
        return fact_[n] * (fact_inv_[k] * fact_inv_[n - k] % mod_) % mod_;
    }

    static long long powm(long long x, long long y, long long mod = 1e9 + 7)
    {
        ll ans = 1;
        while (y > 0) {
            if (y & 0x1) {
                ans = (ans * x) % mod;
            }
            x = (x * x) % mod;
            y >>= 1;
        }
        return ans;
    }

private:
    void build_fact()
    {
        if (!fact_.empty()) {
            return;
        }
        fact_.reserve(N_ + 1);
        fact_.push_back(1);
        for (ll i = 1; i <= N_; i++) {
            fact_.push_back(fact_.back() * i % mod_);
        }
        fact_inv_.resize(N_ + 1);
        fact_inv_[N_] = pow(fact_[N_], mod_ - 2);
        for (ll i = N_ - 1; i >= 0; i--) {
            fact_inv_[i] = fact_inv_[i + 1] * (i + 1) % mod_;
        }
    }

    int N_;
    long long mod_;
    vector<long long> fact_;
    vector<long long> fact_inv_;
};

void solve(long long N, long long M, long long K)
{
    Math m(N, MOD);
    ll ans = 0;
    for (ll i = 0; i <= K; i++) {
        ll val = M * m.pow(M - 1, N - i - 1);
        val %= MOD;
        val *= m.combination(N - 1, i);
        val %= MOD;
        ans += val;
        ans %= MOD;
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    long long K;
    scanf("%lld", &K);
    solve(N, M, K);
    return 0;
}


Measured memory_bytes: 6308
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}
}


Measured memory_bytes: 3132
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int w,h;
long long ww[100005];
long long hh[100005];

int main(){
	cin>>w>>h;
	for(int i=0;i<w;i++) cin>>ww[i];
	for(int i=0;i<h;i++) cin>>hh[i];

	sort(ww,ww+w);
	sort(hh,hh+h);

	ww[w] = 10000000000LL;
	hh[h] = 10000000000LL;

	int wp = 0;
	int hp = 0;

	long long ans = 0;

	for(int i=0;i<w+h;i++){
		if(ww[wp] < hh[hp]) {
			ans += ww[wp] * (h - hp + 1);
			wp++;
		} else if(hh[hp] < ww[wp]){
			ans += hh[hp] * (w - wp + 1);
			hp++;
		} else {
			if(hp > wp){
				ans += ww[wp] * (h - hp + 1);
				wp++;
			} else {
				ans += hh[hp] * (w - wp + 1);
				hp++;
			}
		}
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;

}

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

int main(){
  int N,M,j=0,k=0;
  cin>>N>>M;
  vector<int> A(N,0);
  vector<bool> B(N,true);
  for(int i=0;i<M;i++){
    int p;
    string S;
    cin>>p>>S;
    if(S=="AC"){
      if(B[p-1]){
        j++;
        k+=A[p-1];
        B[p-1]=false;
      }
    }else
      A[p-1]++;
  }
  cout<<j<<' '<<k<<endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

const int N = 100;
char grid[N][N];

// . = write, # = black
int main() {
  int a, b;
  cin >> a >> b;

  rep(i, N) rep(j, N) grid[i][j] = '#';
  rep(i, N / 2) rep(j, N) grid[i][j] = '.';

  for (int i = 0; i < N / 2; i += 2) {
    for (int j = 0; j < N; j += 2) {
      if (b > 1) {
        grid[i][j] = '#';
        b--;
      }
    }
  }

  for (int i = N / 2 + 1; i < N; i += 2) {
    for (int j = 0; j < N; j += 2) {
      if (a > 1) {
        grid[i][j] = '.';
        a--;
      }
    }
  }

  cout << "100 100" << endl;
  rep(i, N) {
    rep(j, N) cout << grid[i][j];
    cout << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int l, min=10000000, max=-10000000;
    long long s=0;
    while(cin >> l){
        s += l;
        if(l<min){
            min = l;
        }
        if(max<l){
            max = l;
        }
    }
    cout << min << " " << max << " " << s << endl;
    return 0;
}


Measured memory_bytes: 3092
n = int(input())
a = list(map(int, input().split()))
min_a  = min(a)
sum_a  = sum(a)
rest = sum_a - n * min_a

def first():
    print("First")
    exit()

def second():
    print("Second")
    exit()

if n % 2 == 1:
    if sum_a % 2 == 0:second()
    if sum_a % 2 == 1:first()

if min_a % 2 == 1:first()

if rest % 2 == 1:first()
if rest % 2 == 0:second()
    


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

int main() {
  int N, M;
  cin >> N >> M;
  int count = 0;
  for (int i = 0; i < M; i++) {
    int tmp;
    cin >> tmp;
    count += tmp;
  }
  int result = N - count >= 0 ? N - count : -1;
  cout << result << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;
	string S;
	cin >> n;
	cin >> S;
	int flag = 0;
	if (n % 2 == 0){
		for (int i = 0;i < n /2;i++){
			if (S[i] == S[n/2 + i]){
				continue;
			}
			else{
				flag = 1;
				break;
			}
		}
	}
	else{
		flag = 1;
	}	
	if (flag == 0){
		cout << "Yes" <<endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int n, ans = 0, i;
    vector <int> v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n * 2; i++) {
        int x;
        
        scanf("%d", &x);
        
        v.push_back(x);
    }
    
    sort(v.begin(), v.end());
    
    for (i = 0; i < n * 2; i += 2) ans += v[i];
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){

  int n,x1,y1,x2,y2,x,y,result=0,i;

  scanf("%d %d %d",&x1,&y1,&n);

  scanf("%d %d",&x1,&y1);

  for(i = 0; i < n-1; i++){

    scanf("%d %d",&x2,&y2);
    x=x2-x1;
    y=y2-y1;
    if(x < 0) x *= -1;
    if(y < 0) y *= -1;

    result += x;
    result += y;

    if((x2-x1)*(y2-y1) > 0){

      if(x > y) result -= y;
      else result -= x;

    }

    // printf("%d\n",result);                                                                                                                                                                  

    x1=x2;
    y1=y2;

  }

  printf("%d\n",result);

  return 0;

}

Measured memory_bytes: 596
#include<iostream>
using namespace std;
int main(){
  int n,home,m=10000,M=0;
  cin >> n;
  for(int i=0; i<n; i++){
    int x;
    cin >> x;
    if(m>=x)m=x;
    if(M<=x)M=x;
  }
  home=M-((m+M)/2);
  //  cout << M <<" "<< m << endl;
  //  cout << m+M << endl;
  // cout << (m+M)/2 << endl;
  cout << home << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

ll gcd(ll a, ll b) {
	if (0 == b)return a;
	return gcd(b, a % b);
}

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

	ll A, B; cin >> A >> B;
	ll mg;
	if (A >= B)mg = gcd(A, B);
	else mg = gcd(B, A);
	bool p[1100000];
	ll cnt = 1;
	int n = sqrt(mg) + 1;
	fill(p, p + n, false);
	for (int i = 2; i <= n; i++) {
		if (p[i] == false) {
			if (mg % i == 0)cnt++;
			while (mg % i == 0)mg /= i;
			int z = i;
			while (z <= n) {
				p[z] = true;
				z += i;
			}
		}
	}
	if (mg > 1)cnt++;
	cout << cnt;
}

Measured memory_bytes: 1280
#include <cstdio>
#include <cstring>
#include <algorithm>

#define N 100010
#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)

inline void read( int &x ){
    x = 0 ; int f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    x *= f ;
}

inline void readl( ll &x ){
    x = 0 ; ll f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    x *= f ;
}

using namespace std ;

int n , m , a[ N ] ,b[N ];
int x ,y ;

int main(){
	int mn = inf , mx = 0 ;
	scanf( "%d%d" , &n , &m ) ;
	in2(x,y);
	for( int i = 1 ; i <= n ; i ++ ) {
		in1( a[ i ] ) ;
	}
	for( int i = 1 ; i <= m ; i ++ ) {
		in1( b[ i ] ) ;
	}
	a[ 0 ] = x ; b [ 0 ]  = y ;
	sort( a , a+ n + 1);
	sort( b , b + m + 1 ) ;
	if( a[ n ] < b[ 0 ] )puts("No War");
	else puts("War");
	return 0 ;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

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 REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	REP(i, N) {
		int Y, M, D;
		cin >> Y >> M >> D;
		int ans = 195 * (Y - 1);
		ans += 5 * ((Y - 1) / 3);
		FOR(i,1, 11) {
			if (i > M)break;
			FOR(j, 1, 21) {
				ans++;
				if (i == M && j == D)break;
				if ((Y % 3) != 0 && (i % 2) == 0 && j == 19)break;
			}
		}
		cout << (195 * 666 + 200 * 333) - ans + 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = acos(-1) ;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw				"\n"


int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0;
	int s{};
	cin>>n>>k;
	while(cin>>x)s+=2*min(x,k-x);
	cout<<s;
}


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

long long gcd(long long a, long long b)
{
  if (a < b) {
    swap(a, b);
  }
  long long r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main()
{
  int N, M;
  while (cin >> N >> M && N != 0) {
    vector<int> p(M);
    for (int i = 0; i < M; i++) {
      cin >> p[i];
    }

    long long n = 0LL;
    double sum = 0.0;
    for (int s = 0; s < (1<<M); s++) {
      const int sign = __builtin_popcount(s) & 1 ? 1 : -1;
      long long lcm = 1LL;
      long long m;
      for (int i = 0; i < M; i++) {
        if (s & (1<<i)) {
          long long g = gcd(lcm, p[i]);
          if (lcm*p[i] > N*g) {
            goto NEXT;
          }
          lcm *= static_cast<long long>(p[i]/g);
        }
      }
      m = N/lcm;
      n += sign * m;
      sum += sign * lcm * m*(m+1LL)/2LL;
NEXT:
      ;
    }
    printf("%.6f\n", n == 0LL ? 0.0 : sum/n);
  }
  return 0;
}

Measured memory_bytes: 956
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;

int main() {
    int A, B; cin >> A >> B;
    set<int> st;
    st.insert(1);
    st.insert(2);
    st.insert(3);
    st.erase(A);
    st.erase(B);

    int ans;
    set<int>::iterator itr = st.begin();
    cout << *itr << endl;
    return 0;
}


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

int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>> c(H, vector<int>(W));
	for (int j = 0; j < H; j++) {
		string temp;
		cin >> temp;
		for (int i = 0; i < W; i++) {

			if (temp[i] == '#') {
				c[j][i] = 1;
			}
			else {
				c[j][i] = 0;
			}
		}
	}
	int ans = 0;
	// 愚直に全部数える
	vector<int> i_line(W, 0), j_line(H, 0);
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			i_line[i] += c[j][i];
		}
	}
	for (int j = 0; j < H; j++) {
		for (int i = 0; i < W; i++) {
			j_line[j] += c[j][i];
		}
	}
	int all_sum = 0;
	for (int j = 0; j < H; j++) {
		for (int i = 0; i < W; i++) {
			all_sum += c[j][i];
		}
	}

	int W_m = (1 << W) - 1;
	int H_m = (1 << H) - 1;
	for (int w = 0; w <= W_m; w++) {
		for (int h = 0; h <= H_m; h++) {
			int temp_sum = all_sum;
			for (int i = 0; i < W; i++) {
				if (((w >> i)&1) == 1) {
					temp_sum -= i_line[i];
				}
			}
			for (int j = 0; j < H; j++) {
				if (((h >> j) & 1) == 1) {
					temp_sum -= j_line[j];
				}
			}
			for (int j = 0; j < H; j++) {
				for (int i = 0; i < W; i++) {
				if (((h >> j) & 1) == 1 && ((w >> i) & 1) == 1)
					temp_sum += c[j][i];
				}
			}
			if (temp_sum == K) {
				ans++;
			}
		}

	}

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

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

int main(){
	int n;
	cin >> n;
	vector<pair<double,double>> p(n);
	rep(i,n){
		cin >> p[i].first >> p[i].second;
	}
	vector<int> d;
	rep(i,n) d.push_back(i);
	
	double sum = 0;
	double count = 0;
	
	do{
		rep(i,n-1){
			double dx = p[d[i+1]].first - p[d[i]].first;
			double dy = p[d[i+1]].second - p[d[i]].second;
			sum += sqrt(dx*dx + dy*dy);
		}
		count++;
	}while(next_permutation(d.begin(),d.end()));
	
	double ans = sum / count;
	printf("%.12f", ans);
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
ll euler_phi(ll n) {
    ll ret = n;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n > 1) ret -= ret / n;
    return ret;
}

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans=0;
    for(int i=0; i<S.size()-2; i++){
        if(S.substr(i, 3) == "ABC"){
            ans++;
        }
    }

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

Measured memory_bytes: 888
#include<stdio.h>

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

    scanf("%d %d %d", &a, &b, &c);
    for(int i = a; i <= b; i++) {
        if(c % i);
        else divisors++;
    }
    printf("%d\n", divisors);

    return 0;
}



Measured memory_bytes: 2108
S = list(input())
ans = 'Yes'
for i in range(0, len(S), 2):
    if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
        pass
    else:
        ans = 'No'
for i in range(1, len(S), 2):
    if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
        pass
    else:
        ans = 'No'

print(ans)

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

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<(a+b)/2+1<<endl;
    
    return 0;
}

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

long table[1000010];
long h[100010];
long N;

long solve(long goal)
{
    if(table[goal]==LONG_MAX){
        table[goal]=std::min(solve(goal-2)+abs(h[goal]-h[goal-2]), solve(goal-1)+abs(h[goal]-h[goal-1]));
    }
    return table[goal];
}


int main()
{
    std::cin >> N;
    for(long i=0; i<N; i++){
        std::cin >> h[i];
        table[i]=LONG_MAX;
    }
    table[0]=0;
    table[1]=abs(h[1]-h[0]);
    std::cout << solve(N-1) << std::endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    if(b <= a+1 || k <= a-1) {
        cout << k+1 << endl;
        return 0;
    }

    ll cnt = 1LL;
    int money = 0;
    for(int t = 1; t <= k; t++) {
        if(t == k) {
            if(money) {
                cnt += b;
            }
            else {
                cnt++;
            }
            break;
        }

        if(money) {
            cnt += b;
            money = 0;
        }
        else {
            if(cnt < a) {
                cnt++;
            }
            else {
                cnt -= a;
                money = 1;
            }
        }
    }

    cout << cnt << endl;
    return 0;
}

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

main()
{
   // ios::sync_with_stdio(0);
   // cout.tie(0);
   // cin.tie(0);
    long long i,j,k,l,m,n,o,p;
 string s;
 while(cin>>s){
    l=s.size();
    int x[150]={0};
    for(i=0;i<l;i++)x[s[i]]++;
    l=0;
    for(i=97;i<123;i++)if(x[i]==0){l++;
        printf("%c\n",i);
        break;
    }
    if(l==0)cout<<"None"<<endl;
 }
    return 0;

}


Measured memory_bytes: 3808
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define mod 1000000007
#define for(i,n) for(int i=0;i<(int)n;i++)
int main(){
  fast();
int t,l;
  cin>>t>>l;
  vector<string> v(t);
  for(i,t)cin>>v[i];
  sort(v.begin(),v.end());
  for(i,t)cout<<v[i];
  return 0;
  
}

Measured memory_bytes: 3672
from math import *
M=55555
tab=[True]*(M+1)
for i in range(2,int(sqrt(M))):
    j=2
    while i*j<=M:
        tab[i*j]=False
        j+=1

N=int(input())
ans=[]
for i in range(2, M+1):
    if tab[i] and i%5==1:
        ans.append(str(i))
        if len(ans)>=N:
            break
print(" ".join(ans))

Measured memory_bytes: 39536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n;
  cin>>n;
  bool can = true;
  rep(i,n){
    int tmp;
    cin>>tmp;
    if(tmp % 2 == 0){
      if(tmp % 3 != 0 && tmp % 5 != 0){
        can = false;
      }
    }
  }
  if(can)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;   // 宣言時ポインタにはNULL(0x0)が入っているため, 木の根が設定されていなければroot == NILとなる.

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }

    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        }
        else {
            y->right = z;
        }
    }
}

bool find(int k) {
    Node *u = root;
    while (u != NIL) {
        if (u->key > k) u = u->left;
        else if (u->key < k) u = u->right;
        else return true;
    }
    return false;
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main() {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else {
            scanf("%d", &x);
            if (find(x)) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}


Measured memory_bytes: 22016
N, K = map(int, input().split())

ans = 0
MOD = 10**9 + 7


def sum(a, b):
    return (b - a + 1) * (a + b) // 2


for i in range(K, N + 2):
    min = sum(0, i - 1)
    max = sum(N - (i - 1), N)
    ans += max - min + 1

print(ans % MOD)


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std; using ll = long long;
using ull = unsigned long long; using P = pair<int, int>;
const int INF = 1e9; const int MOD = 1000000007;
const int dx[] = {-1,0,1,0}; const int dy[] = {0,-1,0,1};
//const int dx[] = {-1,-1,-1, 0, 0, 1, 1, 1}; const int dy[] = {-1, 0, 1,-1, 1,-1, 0, 1};
#define PI 3.14159265358979323846264338327950L //setprecision(15)
// 最大公約数(ユークリッドの互除法)
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	ll A, B, C, D; cin >> A >> B >> C >> D;
	A--;
	ll tmp1 = B / C - A / C;
	ll tmp2 = B / D - A / D;
	ll t = C * D / gcd(C, D);
	ll tmp3 = B / t - A / t;
	A++;
	ll ans = (B - A + 1) - tmp1 - tmp2 + tmp3;
	cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxx = 1010;
int c[maxx][maxx];

int lcs(char s1[],char s2[]) {
    int m = strlen(s1), n = strlen(s2);
    for (int i = 1; i <= m; i++)
        c[i][0] = 0;
    for (int i = 1; i <= n; i++)
        c[0][i] = 0;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            if (s1[i] == s2[j])
                c[i+1][j+1] = c[i][j] + 1;
            else
                c[i+1][j+1] = max(c[i][j+1], c[i + 1][j]);
        }
    }
    return c[m][n];
}
int main()
{
    char s1[maxx], s2[maxx];
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; i++) {
        scanf("%s %s", s1, s2);
        printf("%d\n",lcs(s1,s2));
    }

    return 0;
}


Measured memory_bytes: 7116
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main () {
    long long A, B, X ;
    X = -1 ;
    scanf ( "%lld %lld", &A, &B ) ;
    if ( B != 0 && A % B != 0 ) {
        X = A ;
    }
    printf ( "%lld\n", X ) ;
    return 0 ;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

cnt = 0
flg = True
while flg:
    for i in range(n):
        if a[i] % 2 != 0:
            flg = False
            break
        else:
            a[i] //= 2
    else:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
  int a,b,n,i,j,k;
  cin>>a>>b>>n;
  if(n<(b-1))
  {
    i=a*n;
    i=i/b;
    cout<<i;
  }
  else{
  i=a*(b-1);
  i=i/b;
    cout<<i;
  }
}

Measured memory_bytes: 3604
#include<stdio.h>
int main(){
  int n,q,s[100000],t[50000],i,j,count=0,left,right,mid;

  scanf("%d",&n);
  for(i=0; i < n; i++){
    scanf("%d",&s[i]);
  }
   scanf("%d",&q);
  for(i=0; i < q; i++){
    scanf("%d",&t[i]);
  }
 
  for(i = 0; i < q; i++){
    left = 0;
    right = n;
    while( left < right){
      mid = (left + right) / 2;
      if (s[mid] == t[i]){
	count++;
	break;
      }
      else if(t[i] < s[mid]){
	right = mid;
      }
      else {
	left = mid + 1;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,m,c, ans = 0;
    cin >> n >> m >> c;
    int b[m];
    int a[m];
    for(int i = 0; i < m;i++){
        cin >> b[i];
    }
    for(int i = 0; i < n; i++){
        int temp2 = 0;
        for(int j = 0; j < m; j++){
            int temp;
            cin >> temp;
            temp2 += temp * b[j];
        }
        if(temp2 + c > 0) ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
	int n,temp;
	std::vector<int> a;
	std::cin >> n;
	long long maxnum,minnum;
	int maxx, minx;
	// 1つ目を入力
	std::cin >> temp;
	a.push_back(temp);
	maxnum = minnum = temp;
	maxx = minx = 0;
	for (size_t i = 1; i < n; i++) {
		std::cin >> temp;
		a.push_back(temp);
		if (maxnum < temp) {
			maxnum = temp;
			maxx = i;
		}
		if (minnum > temp) {
			minnum = temp;
			minx = i;
		}
	}

	std::vector<pair<int,int>> ans;

	if (abs(minnum) > abs(maxnum)) {
		for (size_t i = 0; i < n; i++) {
			if (a[i] > 0) {
				a[i] += minnum;
				ans.push_back(make_pair(minx,i));
			}
		}
		for (size_t now = a.size() - 1; now > 0; now--) {
			while (a[now-1] > a[now]) {
				a[now - 1] += a[now];
				ans.push_back(make_pair(now, now-1));
			}
		}
	}
	else {
		for (size_t i = 0; i < n; i++) {
			if (a[i] < 0) {
				a[i] += maxnum;
				ans.push_back(make_pair(maxx,i));
			}
		}
		for (size_t now = 1; now < n; now++) {
			while (a[now - 1] > a[now]) {
				a[now] += a[now-1];
				ans.push_back(make_pair(now-1,now));
			}
		}
	}

	std::cout << ans.size() << '\n';
	for (size_t i = 0; i < ans.size(); i++) {
		std::cout << ans[i].first+1 << ' ' << ans[i].second+1 << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll p=1e9+7;
ll power(ll a,ll b){
	ll ans=1;
	for(;b;b>>=1){
		if(b&1) ans=ans*a%p;
		a=a*a%p;
	}
	return ans%p;
}
int main(){
	ll n;
	cin>>n;
	ll x=power(10,n);
	ll x1=power(9,n);
	ll x2=power(8,n);
	ll ans=(x%p-(2*(x1%p))%p+x2%p+p)%p;
	cout<<ans<<endl;  
	return 0;
}

Measured memory_bytes: 3160
/*
https://atcoder.jp/contests/abc153/tasks/abc153_d

Wins when all monsters health = 0 or below
To Find the mim no of attacks Caracal needs to make before winning

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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    long long h;
    cin>>h;

    long long b = 1;
    while (2 * b <= h)  b *= 2;


        cout << 2 * b - 1;

    return 0;
}

Measured memory_bytes: 256