akhauriyash/Code-Regression huggingface dataset:
H,W=map(int,input().split())
red=[]
blue=[]
for i in range(H):
  A=list(map(int,input().split()))
  red.append(A)
for i in range(H):
  B=list(map(int,input().split()))
  blue.append(B)
list=[[[0 for i in range(80*(j+k+1)+1)] for j in range(W)] for k in range(H)]
list[0][0][abs(red[0][0]-blue[0][0])]=1
for i in range(H):
  for j in range(W):
    for k in range(len(list[i][j])):
      if list[i][j][k]==1:
        if i+1<H:
          if abs(k-abs(red[i+1][j]-blue[i+1][j]))<=80*(i+j+2): 
            list[i+1][j][abs(k-abs(red[i+1][j]-blue[i+1][j]))]=1
          if abs(k+abs(red[i+1][j]-blue[i+1][j]))<=80*(i+j+2): 
            list[i+1][j][abs(k+abs(red[i+1][j]-blue[i+1][j]))]=1
        if j+1<W:
          if abs(k-abs(red[i][j+1]-blue[i][j+1]))<=80*(i+j+2): 
            list[i][j+1][abs(k-abs(red[i][j+1]-blue[i][j+1]))]=1
          if abs(k+abs(red[i][j+1]-blue[i][j+1]))<=80*(i+j+2): 
            list[i][j+1][abs(k+abs(red[i][j+1]-blue[i][j+1]))]=1           
for i in range(12801):
  if list[H-1][W-1][i]==1:
    print(i)
    break


Measured memory_bytes: 419820
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int ar[n];
	for(int i=0;i<n;++i)
		cin>>ar[i];
	int sum=0;
	for(int i=0;i<n-1;++i)
	{
		for(int j=i+1;j<n;++j)
			sum+=(ar[i]*ar[j]);
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a[55];
    int n,k;
    for(int i = 0 ; i <= 55 ; i ++ )
    {
        a[i] = i;
    }
    scanf("%d%d",&n,&k);
    int sum = 0;
    int p = 1;
    int t = 0;
    while(p <= n)
    {
        p ++ ;
        t ++ ;
        if(t == k)
        {
            sum ++ ;
            t = 0;
            p = (p - k) + 1;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)




using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const ll Nmax=1e9;
const ll INF=1e9;

// B貪欲法で決定する．
int main(){
  int d;
  cin>>d;
  vector<int> c(26);
  vector<vector<int>> s(d,vector<int>(26));
  vector<int> last(26);
  vector<int>c_inv(26); // iを選んだ際の1日での下がり幅

  ll c_tot=0;
  rep(i,26){
    cin>> c[i];
    c_tot+=c[i];
    last[i]=-1;
  }
  rep(i,26){
    c_inv[i]=c_tot-c[i];
  }

  rep(i,d){//i日目
    int maxs=-INF;
    int jm=0;

    rep(j,26){
      cin>>s[i][j];
      ll casej=s[i][j];
      rep(k,26){
        if(j!=k){
          casej-=c[k]*(i-last[k]);
        }
      }

      if(casej>maxs){
        maxs=s[i][j]-c_inv[j];
        jm=j;
      }
    }
    last[jm]=i;
    cout<<jm+1<<endl;
  }











}


Measured memory_bytes: 3680
#include <iostream>
#include<iomanip>
#include <cmath>
#include <climits>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>
#include <tuple>
#include <map>
#include <list>
#include <string>
#include <numeric>
#include <utility>
#include <cfloat>

using namespace std;

int main(){
    int A;
    int B;
    int K;

    cin >> A >> B >> K;

    int no = 0;
    for(int i = min(A, B); i >= 1; i--){
        if(A % i == 0 && B % i == 0){
            no ++;
            if(no == K){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, M;
    cin >> N >> M;
    vector<P> items(M);
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        ll d = 0;
        rep(j, b) {
            ll c;
            cin >> c;
            c--;
            d |= (1 << c);
        }
        items[i] = make_pair(a, d);
    }
    vector<ll> dp(1 << N, INF);
    dp[0] = 0;
    rep(i, 1 << N) {
        rep(j, M) {
            P p = items[j];
            dp[i | p.second] = min(dp[i | p.second], dp[i] + p.first);
        }
    }
    ll ans = dp[(1 << N) - 1];
    if (ans == INF) {
        cout << -1 << '\n';
    } else {
        cout << ans << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
// using Rust(1.42.0)
// My Library Repo is at "https://github.com/Loptall/prcn_lib"
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"

/*
    AtCoder Language Update 2020204 お疲れ様でした! 有難いです
*/

// Dep crates are...
use std::cmp::{max, min, Ordering};
use std::collections::{HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::mem::swap;
use std::ops::*;
use std::str::FromStr;

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse()
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().split_whitespace().map(|x| x.parse()).collect()
}

// code...
fn main() {
    let (n, k): (usize, usize) = {
        let inter = input_vec().unwrap();
        (inter[0], inter[1])
    };

    let p: Vec<usize> = input_vec().unwrap();

    let mut mids = Vec::with_capacity(n);
    for i in p {
        mids.push((i + 1) as f64 / 2.);
    }

    let mut ans = mids[..k].iter().sum::<f64>();
    let mut cur = mids[..k].iter().sum::<f64>();
    for i in 0..n-k {
        cur = cur - mids[i] + mids[i+k];
        // println!("{}", cur);
        ans = if ans > cur { ans } else { cur };
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <iostream>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define Rep(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define Repr(i, b, e) for(int (i) = (b) - 1; (i) >= (e); --(i))
#define Print(x) cout << (x) << endl 
#define Min2(a, b) ((a) < (b)) ? (a) : (b)
#define Max2(a, b) ((a) > (b)) ? (a) : (b)

typedef long long ll;

using namespace std;

int main(){
    int N, K;
    string S;
    cin >> N >> S >> K;
    char c = S[K - 1];
    Rep(i, 0, N){
        if(S[i] != c) S[i] = '*';
    }
    Print(S);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll n,cntW=0,cntR=0;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<n;i++)
		if(s[i]=='R')
			cntR++;
	ll ans=cntR;
	for(ll i=0;i<cntR;i++)
		if(s[i]=='R')
			ans--;
	cout<<ans<<endl;
	return 0;
}



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

int main() {
    
    int n ;
    int v[51] , c[51] , max=0  ;
    
    cin>>n ;
    
    for(int i=0 ; i<n ; i++){
        cin>>v[i] ;
    }
    for(int i=0 ; i<n ; i++){
        cin>>c[i] ;
    }
    
    for(int i=0 ; i<n ; i++){
        if(v[i]>c[i]){
            max=max+v[i]-c[i] ;
        }
    }
    cout<<max<<"\n" ;
    
}


Measured memory_bytes: 256
a0, a1, a2 = map(int, input().split())
b0, b1, b2 = map(int, input().split())
c0, c1, c2 = map(int, input().split())
yoko0 = [a0, a1, a2]
yoko1 = [b0, b1, b2]
yoko2 = [c0, c1, c2]
tate0 = [a0, b0, c0]
tate1 = [a1, b1, c1]
tate2 = [a2, b2, c2]
naname0 = [a0, b1, c2]
naname1 = [a2, b1, c0]
n = int(input())
for i in range(n):
    m = int(input())
    if m in yoko0:
        yoko0.remove(m)
    if m in yoko1:
        yoko1.remove(m)
    if m in yoko2:
        yoko2.remove(m)
    if m in tate0:
        tate0.remove(m)
    if m in tate1:
        tate1.remove(m)
    if m in tate2:
        tate2.remove(m)
    if m in naname0:
        naname0.remove(m)
    if m in naname1:
        naname1.remove(m)
if yoko0 == [] or yoko1 == [] or yoko2 == [] or tate0 == [] or tate1 == [] or tate2 == [] or naname0 == [] or naname1 == []:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() {
	map<int, int> mp;
	int n, d;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d;
		mp[d]++;
	}
	cout << mp.size() << endl;
	return 0;
}

Measured memory_bytes: 256
//
// Created by 李青坪 on 2018/11/29.
//

#include <cmath>
#include <cstdio>
#include <algorithm>

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK -2
#define ONLINE_FRONT 2
#define ON_SEGMENT 0
#define EPSLON 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPSLON)

#define MAXN 10000
#define NIL -1
using namespace std;

// 点
class Point {
public:
    double x;
    double y;

    Point() {}

    Point(double x, double y) : x(x), y(y) {}

    Point operator+(Point a) {
        return Point(x + a.x, y + a.y);
    }

    Point operator-(Point a) {
        return Point(x - a.x, y - a.y);
    }

    Point operator*(double a) {
        return Point(x * a, y * a);
    }

    Point operator/(double a) {
        return Point(x / a, y / a);
    }

    double norm() {
        return x * x + y * y;
    }

    double absVector() {
        return sqrt(norm());
    }

    bool operator==(Point a) const {
        return equals(x, a.x) && equals(y, a.y);
    }
};

typedef Point Vector;

// 线段
class Segment {
public:
    Point a, b;
};

typedef Segment Line;

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

Point projection(Segment s, Point point) {
    Vector base = s.b - s.a;
    double t = dot(point - s.a, base) / base.absVector();
    double r = t / base.absVector();
    Point y = base * r;
    Point x = s.a + y;
    return x;
}

Point reflection(Segment s, Point point) {
    return point + (projection(s, point) - point) * 2.0;
}

double getDistance(Point a, Point b) {
    return (a - b).absVector();
}

double getDistanceLine(Line l, Point point) {
    return abs(cross(l.b - l.a, point - l.a) / (l.b - l.a).absVector());
}

double getDistanceSeg(Segment s, Point point) {
    if (dot(s.b - s.a, point - s.a) < 0.0) return (point - s.a).absVector();
    if (dot(s.a - s.b, point - s.b) < 0.0) return (point - s.b).absVector();
    return getDistanceLine(s, point);
}

int ccw(Segment s, Point p) {
    Vector v1 = s.b - s.a;
    Vector v2 = p - s.a;
    if (cross(v1, v2) > 0) return COUNTER_CLOCKWISE;
    if (cross(v1, v2) < 0) return CLOCKWISE;
    if (dot(v1, v2) < 0) return ONLINE_BACK;
    if (v1.norm() < v2.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;
}

bool intersection(Segment s1, Segment s2) {
    return (ccw(s1, s2.a) * ccw(s1, s2.b) <= 0 && ccw(s2, s1.a) * ccw(s2, s1.b) <= 0);
}

double getDistance(Segment s1, Segment s2) {
    if (intersection(s1, s2)) return 0.0;
    return min(min(getDistanceSeg(s1, s2.a), getDistanceSeg(s1, s2.b)),
               min(getDistanceSeg(s2, s1.a), getDistanceSeg(s2, s1.b)));
}

int n;


int main() {
    Segment s[2];
    Point p[4];
    scanf("%d", &n);
    Point point;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 4; ++j) {
            double x, y;
            scanf("%lf %lf", &x, &y);
            point = Point(x, y);
            p[j] = point;
        }
        s[0].a = p[0];
        s[0].b = p[1];
        s[1].a = p[2];
        s[1].b = p[3];
        printf("%.10lf\n", getDistance(s[0], s[1]));
    }
}


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


def main():
    N = int(input())
    a = list(map(int, input().split()))
    A = [0]*8
    n = 0
    for i in a:
        if i >= 3200:
            n += 1
        else:
            A[i//400] = 1
    if sum(A) == 0 and n > 0:
        print(1, n)
    else:
        print(sum(A), sum(A) + n)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef unsigned long long ull;

void merge(int *A, int left, int mid, int right, int *count){
    int n1 = mid-left;
    int n2 = right-mid;
    int L[500001], R[500001];
    for(int i=0;i<n1;i++) L[i]=A[left+i];
    for(int i=0;i<n2;i++) R[i]=A[mid+i];
    L[n1] = INT32_MAX;
    R[n2] = INT32_MAX;

    int i=0, j=0;
    for(int k=left;k<right;k++){
        (*count)++;
        if(L[i]<=R[j]){
            A[k]=L[i];
            i++;
        }else{
            A[k]=R[j];
            j++;
        }
    }
}

void mergeSort(int *A, int left, int right, int *count){
    if(left+1<right){
        int mid = (left+right)/2;
        mergeSort(A, left, mid, count);
        mergeSort(A, mid, right, count);
        merge(A, left, mid, right, count);
    }
}

int main(){
    int n, S[500000];
    cin >> n;
    for(int i=0;i<n;i++) cin >> S[i];

    int count = 0;
    mergeSort(S, 0, n, &count);
    cout << S[0];
    for(int i=1;i<n;i++) cout << ' ' << S[i];
    cout << endl << count << endl;
    
    return 0;
}


Measured memory_bytes: 6928
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8, pi = acos(-1.0);
bool eq(ld a, ld b){return (abs(b-a)<eps);}
ld dot(Point a, Point b){return real(conj(a)*b);}
ld cross(Point a, Point b){ return imag(conj(a)*b);}
int ccw(Point a, Point b, Point c){
  b-=a;c-=a;
  if(cross(b,c)>eps) return 1;//countor_crockwise
  if(cross(b,c)<-eps) return -1;//crockwise
  if(dot(b,c)<0) return 2;//c,a,b
  if(norm(b)<norm(c)) return -2;//a,b,c
  return 0;//a,c,b
}

class Line{
public:
  Point a,b;
};

ld triangle(Point p1, Point p2, Point p3){
  return cross(p2-p1, p3-p1);
}

int intersect(Line l1, Line l2){
  if(l1.a==l2.a||l1.a==l2.b||l1.b==l2.a||l1.b==l2.b){return 1;}
  if(eq(cross(l1.b-l1.a,l2.b-l2.a),0)){
    if(ccw(l1.a,l1.b,l2.a)==0||ccw(l1.a,l1.b,l2.b)==0||ccw(l2.a,l2.b,l1.a)==0||ccw(l2.a,l2.b,l1.b)==0)
      return 1;
    else
      return 0;
  }
  ld a = triangle(l1.a, l1.b, l2.a) * triangle(l1.a, l1.b, l2.b);
  ld b = triangle(l2.a, l2.b, l1.a) * triangle(l2.a, l2.b, l1.b);
  return a <= 0 && b <= 0 ? 1 : 0;
}

int main(){
  int q;cin>>q;
  REP(i,q){
    ld real, imag;
    Line s1,s2;
    cin>>real>>imag;
    s1.a = Point(real,imag);
    cin>>real>>imag;
    s1.b = Point(real,imag);
    cin>>real>>imag;
    s2.a = Point(real,imag);
    cin>>real>>imag;
    s2.b = Point(real,imag);
    cout<<intersect(s1,s2)<<endl;
  }
}

Measured memory_bytes: 1256
N,M = map(int,input().split())

dic = [True for _ in range(M)]

for i in range(N):
    K, *A = list(map(int,input().split()))
    for j in range(M):
        if j+1 in A:
            continue
        else:
            dic[j] = False

print(dic.count(True))

Measured memory_bytes: 3060
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	vector<long long int>a(N);
	vector<long long int>b(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (N & 1) {
		cout << b[N / 2] - a[N / 2] + 1 << endl;
	}
	else {
		cout << b[N / 2] + b[N / 2 - 1] - a[N / 2] - a[N / 2 - 1] + 1 << endl;
	}
}

Measured memory_bytes: 6364
from fractions import gcd
from math import sqrt
A, B = map(int, input().split())
n = gcd(A,B)
ans = 0
i = 2
while i ** 2 <= n:
    if n%i == 0:
        ans += 1
        while n%i == 0:
            n //= i
    i += 1
if n > 1:
    ans += 1
print(ans+1)

Measured memory_bytes: 65768
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	string s;
	cin >> s;
	int i;
	string a = "Yes";
	for (i = 0; i < s.length(); i++)
	{
		if (i % 2 == 1 && s.at(i) == 'R')
			a = "No";
		if (i % 2 == 0 && s.at(i) == 'L')
			a = "No";
	}
	cout << a << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;
    cin>>x>>y;
    if(abs(x-y)<=1){
        cout<<"Brown"<<endl;
    } else{
        cout<<"Alice"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <string>
#include <tuple>

template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(std::min<int>(l_, r_)), r(r_) {}
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): r(std::max<int>(l_, r_) - 1), l(l_ - 1) {}
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

template <class T>
inline T scan() {
  T res;
  std::cin >> res;
  return res;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  for (int &x: A) {
    std::cin >> x;
  }
  for (int x: A) {
    if (x % 2 == 0) {
      if (x % 3 != 0 && x % 5 != 0) {
        std::cout << "DENIED\n";
        return 0;
      }
    }
  }
  std::cout << "APPROVED\n";
  return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=55;
const char to[]={"AKIHABARA"};
char s[N];int n;
int main(){
	scanf("%s",s),n=strlen(s);
	R int i=0,j=0;
	for(;i<n;){
		while(j<9&&s[i]!=to[j]&&to[j]=='A')++j;
		if(j>=9||s[i]!=to[j])return puts("NO"),0;
		++i,++j;
	}
	while(j<9&&to[j]=='A')++j;
	puts(j==9?"YES":"NO");
	return 0;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc152/tasks/abc152_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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 main() {
    ll N; cin>>N;
    vector<ll> pn(N);    
    for(auto&& p:pn){
        cin>>p;
    }
    ll ans=0;
    ll min_v=INT64_MAX;
    for(auto& p:pn){
        if (chmin(min_v, p)){
            ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] abcd=cin.ArrayInt(4,0);
        int ac=Math.Abs(abcd[0]-abcd[2]);
        int ab=Math.Abs(abcd[0]-abcd[1]);
        int bc=Math.Abs(abcd[1]-abcd[2]);
        int d=Math.Abs(abcd[3]);
        string ans="No";
        if(ac<=d||((ab<=d)&&(bc<=d)))ans="Yes";
       Console.WriteLine(ans);
        
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	int a,b;
	cin>>a>>b;
	if(a<=9 && b<=9)cout<<a*b<<endl;
	else cout<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=(int) n;i--)
#define p(s) cout<<(s)<<endl
#define DEBUG(x,y) cout<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl;
#define CK(n,a,b) ((a)<=(n)&&(n)<=(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf=1e9+7;

string s;
int n,k;
int main(){
	cin>>n>>k;
	int a=1;
	REP(i,0,n){
		if(a+k>a*2){
			a*=2;
		}else{
			a+=k;
		}
	}
	p(a);

	return 0;
}


Measured memory_bytes: 256
//DPL_3B
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
 
static const int MAX=1400;

struct Rectangle{int height;int pos;};

int getLagestRectangle(int size,int buffer[]){
 stack<Rectangle> S;
 int maxv=0;
 buffer[size]=0;
 for(int i=0;i<=size;i++){
  Rectangle rect;
  rect.height=buffer[i];
  rect.pos=i;
  if(S.empty()){
   S.push(rect);
  }else{
   if(S.top().height<rect.height){
    S.push(rect);
   }else if(S.top().height>rect.height){
    int target=i;
    while(!S.empty() && S.top().height>=rect.height){
     Rectangle pre=S.top(); S.pop();
     int area=pre.height*(i-pre.pos);
     maxv=max(maxv,area);
     target=pre.pos;
    }
    rect.pos=target;
    S.push(rect);
   }
  }
 }
 return maxv;
}

int H,W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int getLargestRectangle(){
 for(int j=0;j<W;j++){
  for(int i=0;i<H;i++){
   if(buffer[i][j]){
    T[i][j]=0;
   }else{
    T[i][j]=(i>0) ? T[i-1][j]+1:1;
   }
  }
 }
 int maxv=0;
 for(int i=0;i<H;i++){
  maxv=max(maxv,getLagestRectangle(W,T[i]));
 }
 return maxv;
}

int main(){
 cin>>H>>W;
 for(int i=0;i<H;i++){
  for(int j=0;j<W;j++){
   cin>>buffer[i][j];
  }
 }
 cout<<getLargestRectangle()<<endl;
 return 0;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
using namespace std;
long long pow26(long long n){
    if(n==0){
        return 1;
    }else{
        return 26*pow26(n-1);
    }
}

int main(){
    long long n;
    cin >> n;
    n--;
    vector<string> array = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
    long long c = 1;
    while(n >= pow26(c)){
        n = n - pow26(c);
        c++;
    }
    string name = "";
    for(long long i=c-1; i>=0; i--){
        int idx = n / pow26(i);
        n = n % pow26(i);
        name += array.at(idx);
    }
    cout << name << endl;
}

Measured memory_bytes: 3548
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INI(n) scanf("%d",&n)
#define INL(n) scanf("%lld",&n)
#define INF 10000000000
#define mod 1000000007
#define X 100000
#define N 20
#define M 46
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
void nCrReady(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (ll i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll nCr(ll n,ll k){return fac[n]*(finv[k]*finv[n-k]%mod)%mod;}

ll x[200001];
int main(void){
  int k,n;
  scanf("%d %d",&k,&n);
  int a[n];
  FOR(i,n)scanf("%d",&a[i]);
  int ans=a[n-1]-a[0];
  FOR(i,n-1)ans=min(ans,k+a[i]-a[i+1]);
  PRN(ans);
  return 0;
}

Measured memory_bytes: 2484
H, W = map(int, input().split())

h1 = H//3
h2 = h1 + 1
w1 = W//3
w2 = w1 + 1
hh = [h1, h2]
ww = [w1, w2]

ans = float('inf')
for i in range(2):
    s1 = hh[i] * W
    if W % 2 == 0:
        s2 = (W//2) * (H-hh[i])
        s3 = s2
    else:
        s2 = (W//2) * (H-hh[i])
        s3 = s2 + H - hh[i]
    ans = min(ans, max(s1, s2, s3)-min(s1, s2, s3))
    if (H-hh[i]) % 2 == 0:
        s2 = ((H-hh[i])//2) * W
        s3 = s2
    else:
        s2 = ((H-hh[i])//2) * W
        s3 = s2 + W
    ans = min(ans, max(s1, s2, s3)-min(s1, s2, s3))
    s1 = ww[i] * H
    if H % 2 == 0:
        s2 = (H//2) * (W-ww[i])
        s3 = s2
    else:
        s2 = (H//2) * (W-ww[i])
        s3 = s2 + W - ww[i]
    ans = min(ans, max(s1, s2, s3)-min(s1, s2, s3))
    if (W-ww[i]) % 2 == 0:
        s2 = ((W-ww[i])//2) * H
        s3 = s2
    else:
        s2 = ((W-ww[i])//2) * H
        s3 = s2 + H
    ans = min(ans, max(s1, s2, s3)-min(s1, s2, s3))

print(ans)


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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    string s, t;
    cin >> s;

    LL L = s.size();

    for(LL i = 0; i < L; i += 2)
        t.Pb(s[i]);

    cout << t << '\n';

    return 0;
}



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

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


Measured memory_bytes: 256
until (n=gets.to_i) == 0 do
  card = Array.new(n, 0)
  field = 0
  turn = 0
  gets.chop.chars.each do |c|
    case c
      when "M"
        card[turn] += 1
      when "S"
        field += card[turn] + 1
        card[turn] = 0
      when "L"
        card[turn] += field + 1
        field = 0
    end
    turn = (turn+1)%n
  end
  puts [*card.sort, field]*" "
end

Measured memory_bytes: 6104
#include<stdio.h>
int main()
{
	long a,b,k;

	scanf("%ld%ld%ld",&a,&b,&k);
	if(a-k>=0){
		printf("%ld %ld",a-k,b);
		return 0;
	}
	else if(a+b-k>=0){
		printf("0 %ld\n",b+a-k);
		return 0;
	}
	else {
		printf("0 0\n");
		return 0;
	}
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BIT(X, i) ((X>>i)&1)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(a) (a).begin(), (a).end()
#define r_all(a) (a).rbegin(), (a).rend()
#define in(x) cin>>x
#define ina(x, n) rep(x_i,n) cin>>x[x_i]
#define outa(x, n) rep(x_i,n) cout<<x[x_i]<<" \n"[x_i==n-1]

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vll;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = (1<<30);
const ll INFL = (1L<<62);

int main() {
  int H, W, n; cin >> H >> W >> n;
  int y, x; cin >> y >> x;
  string s, t; cin >> s >> t;
  bool ok = true;
  int l, r, u, d;
  l = r = x; u = d = y;
  rep(i,n) {
    if (s[i] == 'L') l--;
    if (s[i] == 'R') r++;
    if (s[i] == 'U') u--;
    if (s[i] == 'D') d++;
    if (l == 0 || r == W+1 || u == 0 || d == H+1) {
      ok = false;
      // cout << i+1 << endl;
      // printf("%d, %d, %d, %d\n", l, r, u, d);
      break;
    }
    if (t[i] == 'R' && l != W) l++;
    if (t[i] == 'L' && r != 1)   r--; 
    if (t[i] == 'D' && u != H) u++;
    if (t[i] == 'U' && d != 1)   d--;
  }
  cout << (ok?"YES":"NO") << endl;
  return 0;
}


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

int main()
{
  int a[200][3];
  int b[200];
  int n;

  cin >> n;

  for (int i = 0; i < n; i++){
    cin >> a[i][0] >> a[i][1] >> a[i][2];
    b[i] = a[i][0] + a[i][1] + a[i][2];
  }
  
  int c;

  for (int j = 0; j < 3; j++){
    for (int i = 0; i < n; i++){
      for (int k = 0; k < n; k++){
        if (k != i && a[i][j] == a[k][j]){
          b[i] -= a[k][j];
          c = -1;
          break;
        }
      }
    }
  }
  
  for (int i = 0; i < n; i++){
    cout << b[i] << endl;
  }

  return 0;
}

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

int main() {
	long long n,m,r,g,b,i,j,k,cur,ans=0,res,zero=0;

	cin >> n;
	vector<string> s(n);
	for(i=0; i<n; i++){
		cin >> s[i];
	}
	
	long long cura=0,curb=0,flag=0;
	for(i=0; i<n; i++){
		if(s[i][0]=='B'){
			curb++;
		}
		if(s[i][s[i].size()-1]=='A'){
			cura++;
			if(s[i][0]!='B'){
				flag++;
			}
		}
		for(j=1; j<s[i].size(); j++){
			if(s[i][j-1]=='A' && s[i][j]=='B'){
				ans++;
			}
		}
	}
	if(flag==0){
		curb=max(curb-1,zero);
	}
	cout << ans+min(cura,curb);

	return 0;
}


Measured memory_bytes: 768
#include <iostream>
//GotoSchool
int main(){
  int N;
  std::cin>>N;
  int a[N],temp;
  for (int i=0;i<N;i++){
    std::cin>>temp;
    a[temp-1]=i+1;
  }
  for (int i=0;i<N-1;i++){
    std::cout<<a[i]<<" ";
  }
  std::cout<<a[N-1]<<std::endl;
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

int main(void){
  int r;
  cin >> r;

  cout << r * r * 3 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    map<ll, ll> num;
    REP(i, N) {
        int tmp;
        cin >> tmp;
        A[i] = tmp;
        num[tmp]++;
    }

    ll total = 0;
    for(auto itr = num.begin(); itr != num.end(); ++itr) {
        total += itr->second * (itr->second - 1) / 2;
    }

    REP(i, N) {
        ll ans = total;
        ans -= num[A[i]] * (num[A[i]] - 1) / 2;
        ans += (num[A[i]] - 1) * (num[A[i]] - 2) /2;
        cout << ans << endl;
    }

    return 0;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    string s;
    cin >> s;
    int cont = 0;

    for ( size_t i = 0; i < s.size() - 1; i++ ) {
        if ( s[i] == s[i + 1] ) {
            s[i + 1] = (s[i + 1] == '0' ? '1' : '0');
            cont++;
        }
    }

    cout << cont << endl;

    return 0;
}

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

signed main(void)
{
	int n, m, d;
	long long sum;
	double ans;

	cin >> n >> m >> d;
	if (d != 0)
	{
		sum = 2 * (n - d);
		ans = (double) sum / n;
		ans /= n;
	}
	else
		ans = (double) 1 / n;
	ans *= m - 1;
	cout << fixed << setprecision(20) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,y;
	while(1)	{
		scanf("%d",&x);
		scanf("%d",&y);
		if(x==0 && y==0)	break;
		if(x < y)	{
			printf("%d %d\n",x,y);
		}
		else {
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}

Measured memory_bytes: 1032
n,x=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in range(n):
    if a[i]>x:
        c+=a[i]-x
        a[i]=x
for i in range(n-1):
    if a[i]+a[i+1]>x:
        c+=a[i+1]-(x-a[i])
        a[i+1]=x-a[i]
print(c)

Measured memory_bytes: 14132
import java.io.*
import java.util.*

fun solve(X: Long, Y: Long){
    // 2^n * X <= Y < 2^(n+1) * X
    var ans = 0
    var x = X
    while(x <= Y){
        x *= 2
        ans++
    }
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val X = sc.next().toLong()
    val Y = sc.next().toLong()
    solve(X, Y)
}



Measured memory_bytes: 29852
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  string N;
  cin>>N;
  int sum=0;
  for(int i=0;i<N.size();i++){
    if(N.at(i)=='2'){
      sum++;
    }
  }
  cout<<sum<<endl;
  
  


  

  



}


  
  


  


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int c = 0;
        for (int i=0; i<n; i++){
            if (i<k){
                c += x;
            }else{
                c += y;
            }
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 21588
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int ans = 0;
        int cur = 0;
        for(int i=0;i<N;i++){
            if(S.charAt(i)=='I') cur++;
            else cur--;
            ans = Math.max(ans,cur);
        }
        System.out.println(ans);
    }
}


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

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

Measured memory_bytes: 256
#include <stdio.h>

int main (void){
	int a,b,c,tmp;
	
	scanf("%d %d %d",&a,&b,&c);
	
	if(a > b){
		tmp = a;
		a = b;
		b =tmp;
	}
	if(b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	if(a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

//        System.err.println(convert(1,1,1));
//        System.err.println(convert(1,10,19));
//        System.err.println(convert(2,1,1));
//
//        System.err.println(convert(2,10,19));
//        System.err.println(convert(3,1,1));
//        System.err.println(convert(3,10,20));
//        System.err.println(convert(4,1,1));
        
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            int y = sc.nextInt();
            int m = sc.nextInt();
            int d = sc.nextInt();
            System.out.println(convert(1000,1,1) - convert(y, m, d));
        }
    }
    
    static int convert(int y, int m, int d) {
        int v19 = 0, v20 = 0;
        y -= 1;
        m -= 1;
        v19 += (y/3 * 2 + y%3)* 5;
        v20 += y/3 * (5+5+10) + y%3 * 5;
        if (y%3 == 2) {
            v20 += m;
        } else {
            v19 += m/2;
            v20 += (m+1)/2;
        }
        return v19 * 19 + v20 * 20 + d;
    }
}

Measured memory_bytes: 20644
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);


const n : number = +input[0];
const s : string = input[1];
const ss = s.split('');

let ans : number = 0;

for  (let i = 0; i < n-2; i++){
    if (ss[i] !== 'A'){ continue; }
    if (ss[i+1] === 'B' && ss[i+2] === 'C'){
        ans += 1;
    }
}
console.log(ans);

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

using namespace std;

void solve(int A, int B, int C, int X) {
  int ans = 0;
  rep(i, A + 1)
    rep(j, B + 1)
    rep(k, C + 1)
    if (500 * i + 100 * j + 50 * k == X)
      ans++;
  cout << ans << endl;
}

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

  int A, B, C, X;
  cin >> A >> B >> C >> X;
  solve(A, B, C, X);
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

typedef long long ll;

using namespace std;

static const int MAX = 1e6+5;

vector<ll> v(MAX);
vector<ll> f(MAX);

int n;
long long k;

bool check(ll x)
{

    ll ct = 0;
    for(int i = 0; i < n; ++i)
    {
        if(v[i] * f[i] > x)
        {
            ct+= v[i] - x/f[i];
        }
    }
    if(ct<= k)
        return true;
    return false;
}

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

    
    cin >> n >> k;
    v.resize(n);
    f.resize(n);

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

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

    sort(v.begin(),v.end());
    sort(f.begin(),f.end(),greater<>());

    ll low = 0, high = 1e12+10;

    ll sol = 0;
    while(low<= high)
    {
        ll mid = low + (high-low)/2;
        if(check(mid))
        {
            sol = mid;
            high = mid-1;
        }
        else
        {
            low = mid+1;
        }
        
    }
    cout << sol;




    return 0;
}


Measured memory_bytes: 16000