akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}
template<class T,enable_if_t<is_integral<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-(-a%b);}
template<class T,enable_if_t<is_floating_point<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-fmod(-a,b);}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    ll t1,t2;
    cin>>t1>>t2;
    ll a1,a2,b1,b2;
    cin>>a1>>a2>>b1>>b2;
    a1-=b1;a2-=b2;
    a1*=t1;
    a2*=t2;
    if(a1<0){
        a1=-a1;
        a2=-a2;

    }
    assert(a1>0);
    if(a1+a2==0){
        print("infinity");
        return 0;
    }
    if(a1+a2>0){
        print(0);
        return 0;
    }
    //a1+a2<0
    ll ans=1;
    ans+=a1/(-(a1+a2))*2;
    ans-=!(a1%(-(a1+a2)));

    print(ans);
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  unsigned long long a;
  long double b;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin>>a>>b;
  long double tmp = (long double)a*b;
  unsigned long long tmp2 = tmp;
  cout<<tmp2;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#pragma GCC optimize("O3")  
#define pb push_back
#define F first
#define S second
using ll = long long;
using namespace std;



void solve(){
	   ll n,m;
	   ll k;        
	   cin>>n>>m>>k;        
	   vector<ll> deska(n);
	   vector<ll> deskb(m);
	   map<ll,ll> mp;
	   map<ll,ll> mp2;
	   for(auto &x:deska) cin>>x;
	   for(auto &y:deskb) cin>>y;	 
	   ll sum=0;
	   ll ans=0;
	   for(ll i=0;i<n;i++){
	   	sum+=deska[i];
	        mp[i+1]=sum;
	 	if(sum>k) continue;
	  	ans=i+1;
	   	  
	   }
	   sum=0;
	   for(ll i=0;i<m;i++){
	   	sum+=deskb[i];
	   	mp2[i+1]=sum;
	   	if(sum>k) continue;
	   	ans=max(ans,i+1); 
	   }
	   ll j=m;                
	   for(ll i=0;i<n;i++){
	         while(j>0 && k-mp[i+1]<mp2[j]){
	            j--;
	         }
	         //cout<<mp[i+1]<<" "<<mp2[j]<<endl;  
	         if(mp[i+1]+mp2[j]<=k && j!=0)ans=max(ans,j+i+1);
	   }
	   cout<<ans<<'\n';



	
}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}






Measured memory_bytes: 31452
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int m = sc.nextInt();
    int n = sc.nextInt();
    char[][] f = new char[m][n];
    for(int i = 0;i<m;i++)
    {
      f[i] = sc.next().toCharArray();
    }
    int[][] dp = new int[m][n];

    if(f[0][0] == '#'){
      dp[0][0] = 1;
    }

    for(int i=1;i<m;i++)
    {
      dp[i][0]=Integer.MAX_VALUE;
      if(f[i-1][0] == f[i][0]||f[i][0] == '.')
          dp[i][0]=Math.min(dp[i][0],dp[i-1][0]);
      else dp[i][0]=Math.min(dp[i][0],dp[i-1][0]+1);
    }
    
    for(int j=1;j<n;j++)
    {
      dp[0][j]=Integer.MAX_VALUE;
      if(f[0][j-1] == f[0][j]||f[0][j] == '.')
          dp[0][j]=Math.min(dp[0][j],dp[0][j-1]);
      else dp[0][j]=Math.min(dp[0][j],dp[0][j-1]+1);
    }

    for(int i=1;i<m;i++) {
      for(int j=1;j<n;j++)
      {
        dp[i][j]=Integer.MAX_VALUE;
        if(f[i-1][j] == f[i][j]||f[i][j] == '.')
        dp[i][j]=Math.min(dp[i][j],dp[i-1][j]);
        else dp[i][j]=Math.min(dp[i][j],dp[i-1][j]+1);

        if(f[i][j-1] == f[i][j]||f[i][j] == '.')
            dp[i][j]=Math.min(dp[i][j],dp[i][j-1]);
        else dp[i][j]=Math.min(dp[i][j],dp[i][j-1]+1);
      }
    }
    System.out.println(dp[m-1][n-1]);
  }
}

Measured memory_bytes: 23636
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<ll>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vecpll vector<pll>
#define vecbl vector<bool>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
string stin(){string s;cin>>s;return s;}

int main(){
    int n=in(),m=in();
    if(n%2==0){
        for(int k=1;k<=m;k++){
            if(k%2==0)cout<<k/2<<" "<<n-k/2<<endl;
            else cout<<n/2+k/2+1<<" "<<n/2-k/2<<endl;
        }
    }else{
        for(int k=1;k<=m;k++){
            cout<<k<<" "<<n+1-k<<endl;
        }
    }
}


Measured memory_bytes: 3700
#include <iostream>
#include <map>
#include <utility>
using namespace std;
typedef pair<int,int> ii;
map<ii,int> m;

int big(int i){
    while (i>=10) i/=10;
    return i;
}

int main(){
    int n;
    cin>>n;
    
    for (int x=1;x<=n;x++){
        m[ii(big(x),x%10)]++;
    }
    
    long long ans=0;
    
    for (int x=1;x<=n;x++){
        ans+=m[ii(x%10,big(x))];
    }
    
    cout<<ans;
}

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

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


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    string s = "";
    if (N == 0) s = "0";
    for (int i = 1; N != 0; i *= -2) {
        if ((N / i) & 1) {
            s = "1"+s;
            N -= i;
        }
        else {
            s = "0"+s;
        }

    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

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

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

int main(){
    ll a;
    cin>>a;
    if(a/1000==a%1000/100 || a%1000/100==a%100/10 || a%100/10==a%10)cout<<"Bad";
    else cout<<"Good";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    long long tmp,x[n],y[n],z[n],sum[n],ans=-10000000000;
    for(int i=0;i<n;i++)
    cin>>x[i]>>y[i]>>z[i];
    
    for(int i=0;i<8;i++)
    {
        tmp=0;
        for(int i=0;i<n;i++)
        sum[i]=0;
        if(i&1)
        {
            for(int k=0;k<n;k++)
            {
                sum[k]+=x[k];
            }
        }
        else
        {
            for(int d=0;d<n;d++)
            {
                sum[d]-=x[d];
            }
        }
        if(i&2)
        {
            for(int p=0;p<n;p++)
            {
                sum[p]+=y[p];
            }
        }
        else
        {
            for(int l=0;l<n;l++)
            {
                sum[l]-=y[l];
            }
        }
        if(i&4)
        {
            for(int t=0;t<n;t++)
            {
                sum[t]+=z[t];
            }
        }
        else
        {
            for(int s=0;s<n;s++)
            {
                sum[s]-=z[s];
            }
        }
        sort(sum,sum+n);

        for(int k=n-1;k>=n-m;k--)
        tmp+=sum[k];
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    n = II()
    k = II()
    xx = MII()
    sumv = 0
    for x in xx:
        sumv += min(x,abs(x-k))*2
    print(sumv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    M, *DC = map(int, read().split())
    D = DC[::2]
    C = DC[1::2]

    total = sum(d * c for d, c in zip(D, C))
    ans = sum(C) - 1 + (total - 1) // 9
    print(ans)
    return


if __name__ == '__main__':
    main()


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

using namespace std;

string x = "MARCH";

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> wyst(5, 0);
    for (int i = 0; i < n; ++i)
    {
        string im;
        cin >> im;
        for (int j = 0; j < 5; ++j)
            if (x[j] == im[0])
                ++wyst[j];
    }
    ll odp = 0;
    for (int i = 0; i < 5; ++i)
        for (int j = i + 1; j < 5; ++j)
            for (int k = j + 1; k < 5; ++k)
                odp += wyst[i] * wyst[j] * wyst[k];
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
import collections

n=int(input())
s = [0 for i in range(n)]

for i in range(n):
    s_in = str(input())
    s_in = list(s_in)
    s_in.sort()
    s_in = "".join(s_in)
    s[i] = s_in
    
s_col = collections.Counter(s)
s_set = set(s)

cnt = 0

for i in s_set:
    cnt += (s_col[i])*(s_col[i]-1)/2
print(int(cnt))
    

Measured memory_bytes: 23424
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;

#define mp make_pair
#define pb push_back
#define x first
#define y second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

const int N=500010;
const int mod=1000000007;

int a[N],s1[N],s2[N],s3[N],fac[N],c[N];
bool ok[N];

int lowbit(int x) {return x&(-x);}

void change(int x,int n)
{
	while (x<=n)
	{
		c[x]++;x+=lowbit(x);
	}
}

int query(int x)
{
	int s=0;
	while (x)
	{
		s+=c[x];x-=lowbit(x);
	}
	return s;
}

int main()
{
	int n;scanf("%d",&n);
	for (int i=1;i<=n;i++) {scanf("%d",&a[i]);ok[a[i]]=1;}
	s1[0]=0;for (int i=1;i<=n;i++) if (!ok[i]) s1[i]=s1[i-1]+1; else s1[i]=s1[i-1];
	s2[n+1]=0;for (int i=n;i;i--) if (!ok[i]) s2[i]=s2[i+1]+1; else s2[i]=s2[i+1];
	fac[0]=1;for (int i=1;i<=n;i++) fac[i]=ll(fac[i-1])*i%mod;
	s3[0]=0;for (int i=1;i<=n;i++) if (!a[i]) s3[i]=(s3[i-1]+fac[n-i])%mod; else s3[i]=s3[i-1];
	int ans=0;
	int cnt=0,k=s1[n];
	for (int i=n;i;i--)
		if (a[i])
		{
			if (k) ans=(ll(s2[a[i]])*s3[i]%mod*fac[k-1]+ans)%mod;
			if (k) ans=(ll(s1[a[i]])*cnt%mod*fac[n-i]%mod*fac[k-1]+ans)%mod;
			ans=(ll(query(a[i]))*fac[n-i]%mod*fac[k]+ans)%mod;
			change(a[i],n);
		}
		else
		{
			if (k>1) ans=(ll(k)*(k-1)/2%mod*cnt%mod*fac[n-i]%mod*fac[k-2]+ans)%mod;
			cnt++;
		}
	printf("%d\n",(ans+fac[k])%mod);
	return 0;
}


Measured memory_bytes: 12416
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 

int main(void) {
  int a,b,m;cin>>a>>b>>m;
  vector<int> A(a), B(b);
  fr(i,a) cin>>A[i];
  fr(i,b) cin>>B[i];
  int ans = 1e6;
  fr(i,m){
    int x,y,c;cin>>x>>y>>c;
    ans = min(ans, A[x-1] + B[y-1] - c);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  ans = min(ans, A[0]+B[0]);
  
 cout << ans << endl;
  return 0;
}

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

int main(){
  long long n,z=1,ans=0;
  cin>>n;
  for(long long i=1;i<=n;i++){ 
    long long x=n/i;
    ans=ans+x*(x+1)*i/2;
  }
  cout <<ans;
}

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

int main(){

    int n;
    cin >> n;

    map<string, int> dict;

    
    string buf, memo;
    cin >> memo;
    dict[memo]++;
    for (int i=1; i<n; i++){
        cin >> buf;
        dict[buf]++;

        if (buf.at(0) != memo.at(memo.size()-1)){
            cout << "No" << endl;
            return 0;
        }
        memo = buf;
    }

    for (auto p: dict){
        auto value = p.second;

        if (value != 1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    vector <int> s(m), c(m);
    for (int i = 0; i < m; i++)
        cin >> s[i] >> c[i];

    for (int i = 0; i <= 999; i++) {
        bool ok = 1;
        vector <int> e;
        int tt = i;
        if (i == 0) e.push_back(0);
        while (tt) {
            e.push_back(tt % 10);
            tt /= 10;
        }
        if (e.size() != n) continue;
        for (int j = 0; j < m; j++)
            if (e[e.size() - s[j]] != c[j]) ok = 0;
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(){
  while(1){
  int a;
  int b,c=0,d=0,e=0,f=0,g=0,h=0;
  int sum=0;
  
  scanf("%d",&a);
  if(a==0)break;
  b=1000-a;

  if(b/500!=0)c=b/500;
  if(b%500/100!=0)d=b%500/100;
  if(b%100/50!=0)e=b%100/50;
  if(b%50/10!=0)f=b%50/10;
  if(b%10/5)g=b%10/5;
  if(b%5)h=b%5;
  printf("%d\n",c+d+e+f+g+h);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#include <random>
#include <atcoder/all>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\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; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<lint, char> pa;

using namespace atcoder;
lint N, M;
int main() {
	cin >> N >> M;
	vector<lint> arr(N), _arr(M);
	REP(i, N) {
		cin >> arr[i];
	}
	REP(i, M) {
		cin >> _arr[i];
	}
	for (auto itr : convolution(arr, _arr)) {
		cout << itr << " ";
	}
	cout << endk;	
}


Measured memory_bytes: 27216
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	static const ULL M = 1000000007;

	vector<ULL> F, I, iF;
	vector<ULL> iP2;

	ULL C(UL n, UL r) { return F[n] * iF[r] % M * iF[n - r] % M; }

	void Solve() {
		ULL B, W; cin >> B >> W;
		ULL SZ = B + W;
		F.resize(SZ + 1); F[0] = 1;
		for (UL i = 1; i <= SZ; i++) F[i] = F[i - 1] * i % M;
		I.resize(SZ + 1); I[1] = 1;
		for (UL i = 2; i <= SZ; i++) I[i] = M - M / i * I[M % i] % M;
		iF.resize(SZ + 1); iF[0] = 1;
		for (UL i = 1; i <= SZ; i++) iF[i] = iF[i - 1] * I[i] % M;
		iP2.resize(SZ + 1); iP2[0] = 1;
		for (UL i = 1; i <= SZ; i++) iP2[i] = iP2[i - 1] * I[2] % M;

		vector<ULL> NB(SZ), NW(SZ);
		rep(i, SZ) {
			if (i >= B) {
				NB[i] = iP2[i] * C(i - 1, B - 1);
				NB[i] += NB[i - 1];
				NB[i] %= M;
			}
			if (i >= W) {
				NW[i] = iP2[i] * C(i - 1, W - 1);
				NW[i] += NW[i - 1];
				NW[i] %= M;
			}
		}

		rep(i, SZ) {
			ULL ans = NW[i];
			ULL buf = (1 + M + M - NB[i] - NW[i]) % M;
			buf = buf * I[2] % M;
			ans = (ans + buf) % M;
			cout << ans << endl;
		}
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class F> struct lazy_segtree {
  const int n;
  vector<T> t;
  vector<F> d;
  lazy_segtree(int _n = 0) : n(_n), t(2 * n), d(n) {}
  T& operator[](int i) { return t[n + i]; }
  void build() { for (int i = n; i--; ) t[i] = t[2 * i] * t[2 * i + 1]; }
  void apply(int i, F f) {
    t[i] = f(t[i]);
    if (i < n) d[i] = d[i] * f;
  }
  void push(int i) {
    apply(2 * i, d[i]), apply(2 * i + 1, d[i]);
    d[i] = F();
  }
  void push_down(int i) {
    for (int h = __lg(i), tz = __builtin_ctz(i); h > tz; --h) push(i >> h);
  }
  void pull_up(int i) {
    while (i >>= 1) t[i] = t[2 * i] * t[2 * i + 1];
  }
  T fold(int l, int r) {
    push_down(l += n), push_down(r += n);
    T a, b;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) a = a * t[l++];
      if (r & 1) b = t[--r] * b;
    }
    return a * b;
  }
  T get(int i) { return fold(i, i + 1); }
  void act(int l, int r, F f) {
    push_down(l += n), push_down(r += n);
    for (int i = l, j = r; i < j; i >>= 1, j >>= 1) {
      if (i & 1) apply(i++, f);
      if (j & 1) apply(--j, f);
    }
    pull_up(l >> __builtin_ctz(l)), pull_up(r >> __builtin_ctz(r));
  }
  void set(int i, T a) {
    push_down(i += n), push_down(i + 1);
    t[i] = a;
    pull_up(i);
  }
};

template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

template <class T> struct mini {
  T v = inf<T>;
  mini operator*(mini b) const {
    return b.v < v ? b : *this;
  }
};
struct chmin {
  int v = 1e9;
  chmin operator*(chmin g) const {
    return {min(v, g.v)};
  }
  mini<int> operator()(mini<int> x) const {
    return {min(x.v, v)};
  }
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> b(n);
  for (auto&& e : b) cin >> e;
  int m;
  cin >> m;
  vector<vector<int>> ls(n + 1);
  while (m--) {
    int l, r;
    cin >> l >> r;
    --l;
    ls[r].push_back(l);
  }
  vector<int> cum(n + 1);
  for (int i = n; i--; ) {
    cum[i] = (1 - b[i]) + cum[i + 1];
  }
  lazy_segtree<mini<int>, chmin> seg(n + 1);
  seg.set(0, {cum[0]});
  for (int r = 1; r <= n; ++r) {
    seg.set(r, {cum[r] + (seg.get(r - 1).v - cum[r - 1]) + b[r - 1]});
    for (int l : ls[r]) {
      seg.act(l + 1, r + 1, {seg.get(l).v});
    }
  }
  cout << seg.get(n).v << '\n';
}


Measured memory_bytes: 14464
import java.util.*;
public class Main{
public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
  String po=sc.nextLine();
  char[]c=po.toCharArray();
  Arrays.sort(c);
  po="";
  for(int i=0;i<c.length;i++){
      po+=c[i];
  }
  
  String po2=sc.nextLine();
  char[]c2=po2.toCharArray();
  Arrays.sort(c2);
  po2="";
  for(int i=0;i<c2.length;i++){
      po2+=c2[c2.length-1-i];
  }
  System.out.println((po.compareTo(po2)<0)?"Yes":"No");
}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string S;
    cin >> S;
    if(S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

Measured memory_bytes: 3656
require 'date'
require 'pp'

era = [[1868, 9, 8], [1912, 7, 30], [1926, 12, 25], [1989, 1, 8]].map {
  |d| Date.new(d[0], d[1], d[2])
}
names = ["pre-meiji", "meiji", "taisho", "showa", "heisei"]

while ((line = $stdin.gets) != nil) do
  date = line.chomp.split(" ").map(&:to_i)
  d = Date.new(date[0], date[1], date[2]);
  ans = 0
  dates = (era + [d]).sort
  dates.each_with_index do |x, i|
    ans = i if (x == d)
  end
  if (ans == 0) then puts "#{names[ans]}"
  else
    puts "#{names[ans]} #{d.year - dates[ans - 1].year + 1} #{d.month} #{d.day}"
  end
end

Measured memory_bytes: 6392
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include<unordered_map>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;


int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;
	double concentration = 0.00000;
	double water = 0.00000;
	double sugar = 0.00000;
	rep(i, 101) {
		rep(j, 101) {
			rep(k, 101) {
				rep(m, 101) {
				
					double tmpwater = 100.00000 * A*i + 100.00000 * B*j;
					double tmpsugar = C * k + D * m;
					double maxsugar = tmpwater * E / 100.00000;
					if (tmpsugar + tmpwater <= F
						&&tmpsugar+tmpwater!=0
						&&tmpsugar<=maxsugar) {
						double tmp =
							100.00000 * tmpsugar / (tmpsugar+tmpwater);
						if (concentration<tmp) {
							concentration = tmp;
							water = tmpwater;
							sugar = tmpsugar;
						}

					}
				}
			}
		}
	}
	if (water == 0) {
		water = 100*A;
	}
	cout << water+sugar << " " << sugar;
}


Measured memory_bytes: 384
#include <stdio.h>
#define MAX 100
int g[MAX][MAX],d[MAX],f[MAX],t=1;

void dfs(int i){
  int j;
  if(d[i] == 0){
    d[i] = t;
    t++;
    for(j = 1; g[i][j] != -1; j++) if(d[g[i][j]] == 0) dfs(g[i][j]);
    f[i] = t;
    t++;
  }
}

int main(){
  int n,i,j,u,k;
  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    scanf("%d%d",&u,&k);
    for(j = 1; j <= k; j++) scanf("%d",&g[i][j]);
    g[i][j] = -1;
  }
  for(i = 1; i <= n; i++) dfs(i);
  for(i = 1; i <= n; i++) printf("%d %d %d\n",i,d[i],f[i]);
  return 0;
}



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

#define fast ios::sync_with_stdio(0) , cin.tie(0)
#define pb push_back
#define deb(x) cout << "[ " << #x << " = " << x << " ]\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()


const int SZ = 1e5 + 5;

int main(){
   fast;
   int n,m,k;
   cin >>n >> m >>k;
   int ans = 1e9 + 10;

   int mat[n][m];

   int C[n];

   for(int i=0 ; i<n ;++i){
      for(int j=0 ;j<m+1 ; ++j){
         if( j == 0) cin >> C[i];
         else{
            cin >> mat[i][j-1];
         }
      }
   }

   for( int i = 0 ; i < (1<<n) ; ++i){
      int cost = 0;
      vector<int> c(m,0);
      for( int j = 0 ; j < n ; ++j){
         if( (i>>j) & 1 ){
            cost += C[j];
            for( int e = 0 ; e < m ; ++e ){
               c[e] += mat[j][e];
            }
         }
      }
      bool ok = 1;
      for( int j = 0 ; j < m ; ++j ){
         if( c[j] < k ) ok = 0;
      }
      if(ok) ans = min(ans , cost);
   }
   if(ans != 1e9 + 10 ) cout << ans;
   else cout << -1; 
   return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
using namespace std;
int main() {
  int n, h[100000], dp[100000][2] = {};
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &h[i]);
  }
  dp[0][0] = 1;
  dp[0][1] = 1;
  for (int i = 1; i < n; i++) {
    if ((dp[i - 1][0] && h[i] >= h[i - 1]) ||
        (dp[i - 1][1] && h[i] >= h[i - 1] - 1)) {
      dp[i][0] = 1;
    }
    if ((dp[i - 1][0] && h[i] >= h[i - 1] + 1) ||
        (dp[i - 1][1] && h[i] >= h[i - 1])) {
      dp[i][1] = 1;
    }
  }
  if (dp[n - 1][0] || dp[n - 1][1]) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

Measured memory_bytes: 1280
N,K = map(int,input().split())
d = [0 for _ in range(K)]
A = [[] for _ in range(K)]
for i in range(K):
    d[i] = int(input())
    A[i] = list(map(int,input().split()))
su_list = [i for i in range(1,N+1)]
for i in range(K):
    for j in range(d[i]):
        if A[i][j] in su_list:
            su_list.remove(A[i][j])        
print(len(su_list))

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

int p[11][11];
int dp[MAX_N];
int n,d,x;

int main()
{
	scanf("%d%d%d",&n,&d,&x);
	rep(i,d){
        rep(j,n){
            scanf("%d",&p[i][j]);
        }
	}
    rep(j,d-1){
        rep(k,100001){
            dp[k] = k;
        }
        rep(k,n){
            rep(i,100001){
                if(i >= p[j][k]){
                    dp[i] = max(dp[i],dp[i-p[j][k]]+p[j+1][k]);
                }
            }
        }
        x = dp[x];
    }
    printf("%d\n",x);
	return 0;
}

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

int main(){
	int a, b;
	char c;
	for(int i=0; i>=0; i++){
		cin >> a >> c >> b;
		if(c=='?') break;
		if(c=='+') cout << a+b << endl;
		if(c=='-') cout << a-b << endl;
		if(c=='*') cout << a*b << endl;
		if(c=='/') cout << a/b << endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int r = n % 10;
    string ans = "bon";
    if (r == 2 || r == 4 || r == 5 || r == 7 || r == 9) ans = "hon";
    if (r == 0 || r == 1 || r == 6 || r == 8) ans = "pon";
    cout << ans << endl;
}

Measured memory_bytes: 3596
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	double a, b, n;
	scanf("%lf%lf%lf", &a, &b, &n);
	printf("%d\n", (int)(floor(a * min(n, b - 1.0) / b) - a * floor(min(n, b - 1.0) / b)));

	Please AC;
}


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

using lli = long long int;

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

int main(void){
    int x;
    cin >> x;
    vector<bool> ptable = prime_table(1e6);
    for(int i = x; i <= 1e6; i++){
        if(ptable[i] == true){
            cout << i << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

int main() {
  int N;
  int i; 
  int tmp; 
  int *a; 
  
  cin >> N; 

  a = new int[N+1];
  
  for(i=1;i<N+1;i++){
    scanf("%d",&tmp);
    a[tmp] = i; 
  }
  
  for(i=1; i<N+1; i++){    
    printf("%d ",a[i]);
  }
  
  return 0;
}


Measured memory_bytes: 1152
#include <cstdio>

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

using namespace std;

int main(){
	char s[4],t[4];
	scanf("%s%s",s,t);

	int cnt=0;
	rep(i,3) if(s[i]==t[i]) cnt++;
	printf("%d\n",cnt);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);
    Int a, b, q;
    cin >> a >> b >> q;
    vector<Int> s(a), t(b), x(q);
    for (Int i = 0; i < a; i++) cin >> s[i];
    for (Int i = 0; i < b; i++) cin >> t[i];
    for (Int i = 0; i < q; i++) cin >> x[i];
    for (Int i = 0; i < q; i++) {
        Int ps = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
        Int pt = lower_bound(t.begin(), t.end(), x[i]) - t.begin();
        Int s1, s2, t1, t2;
        if (ps == 0) {
            s1 = -1;
            s2 = s[0];
        }
        else if (s.back() < x[i]) {
            s1 = s.back();
            s2 = INF;
        }
        else {
            s1 = s[ps - 1];
            s2 = s[ps];
        }
        if (pt == 0) {
            t1 = -1;
            t2 = t[0];
        }
        else if (t.back() < x[i]) {
            t1 = t.back();
            t2 = INF;
        }
        else {
            t1 = t[pt - 1];
            t2 = t[pt];
        }
        Int res = 1e18;
        if (s1 != -1 && t1 != -1) {
            Int mi = 0;
            mi += min(abs(s1 - x[i]), abs(t1 - x[i]));
            mi += abs(s1 - t1);
            res = min(res, mi);
        }
        if (s1 != -1 && t2 != INF) {
            Int mi = 0;
            mi += min(abs(s1 - x[i]), abs(t2 - x[i]));
            mi += abs(s1 - t2);
            res = min(res, mi);
        }
        if (s2 != INF && t1 != -1) {
            Int mi = 0;
            mi += min(abs(s2 - x[i]), abs(t1 - x[i]));
            mi += abs(s2 - t1);
            res = min(res, mi);
        }
        if (s2 != INF && t2 != INF) {
            Int mi = 0;
            mi += min(abs(s2 - x[i]), abs(t2 - x[i]));
            mi += abs(s2 - t2);
            res = min(res, mi);
        }
        dump(res);
    }
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) {cin >> a[i]; a[i]--;}
    
    vector<int> ans(n);
    rep(i,n) ans[a[i]] = i;

    rep(i,n) printf("%d%c",ans[i]+1,i==n-1? '\n':' ');
}

Measured memory_bytes: 1536
while True:
    n = int(input())
    if n == 0:
        break

    a = [int(input()) for i in range(n)]

    sum = [0 for i in range(n + 1)]
    for i in range(n):
        sum[i + 1] = sum[i] + a[i]

    ans = -(10**18)
    for i in range(n + 1):
        for j in range(1, i + 1):
            ans = max(ans, sum[i] - sum[i - j])

    print(ans)



Measured memory_bytes: 5716
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h, w, n,m,k; string s,t;
char maze[60][60];
int dis[101][101]; int graph[52][52]; bool vis[52];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}

int main() {
	cin >> n;
	ll cnt = 0;
	cnt = (1 + n - 1) * (n - 1) / 2;
	cout << cnt << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define M 1000000007
#define pi acos(-1)
/*ll power(ll a,ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res*a)%M;
        a = (a*a)%M;
        b = b >> 1;
    }
    return res;
}*/
/*ll modinv(ll a)
{
   return power(a,M - 2); 
}*/
/*vector<ll> primes(ll n)
{
    bool *sieve = new bool[n + 1];
    ll i,j;
    vector<ll> v;
    for(i = 3; i <= n; i+=2)
        sieve[i] = true;
    sieve[2] = true;
    for(i = 3; i*i <= n; i+=2)
    {
        if(sieve[i])
            for(j = i*i; j <= n; j+=i)
                sieve[j] = false;
    }
    if(n >= 2)
    {
        v.pb(2);
        for(i = 3; i <= n; i+=2)
        {
            if(sieve[i])
                v.pb(i);
        }
    }
    return v;
}*/

/*class graph{
public:
    vector<ll> *g;
    ll n;
    graph(ll v)
    {
        n = v + 1;
        g = new vector<ll> [n];
    }
    void addegde(ll f,ll s)
    {
        g[f].pb(s);
        g[s].pb(f);
    }
    void dfs(bool *visited,ll sv)
    {
        visited[sv] = true;
        for(auto x: g[sv])
        {
            if(!visited[x])
            {
                dfs(visited,x);
            }
        }
    }
    void bfs(ll sv){
       queue<ll> q;
       bool visited[n] = {};
       q.push(sv);
       visited[sv] = true;
       while(!q.empty())
       {
           ll node = q.front();
           q.pop();
           for(auto x : g[node])
           {
               if(!visited[x])
               {
                   visited[x] = true;
                   q.push(x);
               }
           }
       }
    }
};*/
int main()
{
    fast;
    ll i,j,t;
    ll n;
    cin >> n;
    bool flag = true;
    ll a[n];
    for(i = 0; i < n; i++)
        cin >> a[i];
    for(i = 0; i < n; i++)
    {
        if((a[i] % 2 == 0) && a[i] % 3 != 0 && a[i] % 5 != 0)
        {
            flag = false;
            break;
        }
    }
    if(flag)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
    return 0;
}



Measured memory_bytes: 256
N=int(input())
P=[int(input()) for _ in range(N)]
Q=[0 for _ in range(N)]

for i in range(N):
    Q[P[i]-1]=i

cnt=0
tmp=0
for i in range(N-1):
    if Q[i]<Q[i+1]:
        cnt+=1
    else:
        if tmp<cnt+1:
            tmp=cnt+1
        cnt=0

if tmp==0:
    tmp=cnt+1

print(N-tmp)


Measured memory_bytes: 18888
fun main(arr:Array<String>) {
    val (n,k,q) = readLine()!!.split(" ").map { it.toLong() }
    val score = (1..n.toInt()).map { 0 }.toTypedArray()
    for(i in (1..q)) {
        score[readLine()!!.toInt()-1]++
    }
    for(i in score) {
        println(if(i + k - q > 0) "Yes" else  "No")
    }
}


Measured memory_bytes: 45872
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<vector<ll>> d(210,vector<ll>(210, 1e18));
vector<ll> r(10);


void warshall_floyd(int n) { // nは頂点数
  for (int i = 0; i < n; i++)      // 経由する頂点
    for (int j = 0; j < n; j++)    // 開始頂点
      for (int k = 0; k < n; k++)  // 終端
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
}

ll dfs(ll R, ll cnt, ll flag, ll sum, ll cur){
    if(cnt == R - 1){
        return sum;
    }
    ll m = 1e18;
    rep(i,R){
        if(((1LL) << i) & flag) continue;
        cmin(m, dfs(R, cnt+1, flag | ((1LL) << i), sum + d[cur][r[i]], r[i]));
    }
    return m;
}

int main(){
    ll N,M,R;
    cin >> N >> M >> R;
    rep(i,R){
        cin >> r[i];
        r[i]--;
    }
    vector<vector<ll>> G(N),C(N,vector<ll>(N));
    ll a,b,c;
    rep(i,M){
        cin >> a >> b >> c;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyd(N);
    ll ans = 1e18;
    rep(i,R){
        cmin(ans, dfs(R, 0, ((1LL) << i), 0, r[i]));
    }
    cout << ans << endl;
}



Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
#include <map>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <stack>
#include <cassert>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie();
    
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); ++i) {
        s[i] = 'x';
    }
    cout << s;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main() {
  double ans, R, G;
  cin >> R >> G;
  ans = 2 * G - R;
  cout << ans << endl;
    
}



Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
from itertools import *
ans = 0
for bit in range(1<<(h+w)):
    c = 0
    for i, j in product(range(w, h+w), range(w)):
        if bit>>i & 1 and bit>>j & 1: c += C[i-w][j] == '#'
    if c == k: ans += 1
print(ans)


Measured memory_bytes: 10508
#include<stdio.h>
    #include<string.h>
    int main(void){
    int A,B,C,D,E,N,M,x,y,i,j,cou=0,cou2,v[1000000],w[1000000],min_i,en=0;
        char S[100],W[100],s[10],X,Y;
       scanf("%d",&A);
           printf("%d",A/3);
       return 0;
    }

Measured memory_bytes: 128
def make_bscg(i, r, s):
    if i == r:
        return [s]
    ans = []
    ans += make_bscg(i+1, r, s+"3")
    ans += make_bscg(i+1, r, s+"5")
    ans += make_bscg(i+1, r, s+"7")
    return ans


def is_753(x):
    s, f, t = x.count("7"), x.count("5"), x.count("3")
    c = s + f + t
    return s >= 1 and f >= 1 and t >= 1 and c == len(x)
    

N = input()
nn = int(N)
broad_scg = [p for i in range(3, len(N)+1) for p in make_bscg(0, i, "")]
ans = 0
for bscg in broad_scg:
    if int(bscg) > nn:
        break
    if is_753(bscg):
        ans += 1
print(ans)

Measured memory_bytes: 5364
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

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

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

    vec<int> dp(k, 0);
    rep(i, k) rep(j, n) {
        if (i+1-a[j]>=0) dp[i+1] = 1 - (dp[i+1-a[j]]) * (1-dp[i+1]);
    }
    if (dp[k] == 1) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,j;
	scanf("%d",&n);
	vector<int>x(1<<n),r(1<<n),m(1<<n);
	for(auto &e:x)scanf("%d",&e);
	for(i=0;i<1<<n;i++)for(j=i;j<1<<n;j=(j+1)|i){
		r[j]=max(r[j],x[i]+m[j]);
		m[j]=max(m[j],x[i]);
	}
	for(i=1;i<1<<n;i++)printf("%d\n",r[i]=max(r[i],r[i-1]));
}

Measured memory_bytes: 6144
use io::*;

fn main() {
    let input = read_string();
    let mut sc = Scanner::new(&input);
    let n: usize = sc.next();
    let m: usize = sc.next();
    let mut v1 = vec![false;n];
    let mut v2 = vec![false;n];
    for i in 0..m {
        let a: usize = sc.next();
        let b: usize = sc.next();
        if a == 1 {
            v1[b-1] = true;
        } else if b == n {
            v2[a-1] = true;
        }
    }
    for i in 0..n {
        if v1[i] && v2[i] {
            println!("POSSIBLE");
            return;
        }
    }
    println!("IMPOSSIBLE");
}

pub mod io {
    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }

        pub fn next_mat<T: FromStr>(&mut self, w: usize, h: usize) -> Vec<Vec<T>> {
            (0..h).map(|_| self.next_vec(w)).collect()
        }

        pub fn next_vec_char(&mut self) -> Vec<char> {
            self.next::<String>().chars().collect()
        }

        pub fn next_mat_char(&mut self, n: usize) -> Vec<Vec<char>> {
            (0..n).map(|_| self.next_vec_char()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

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


Measured memory_bytes: 9848