akhauriyash/Code-Regression huggingface dataset:
S = input()
Q = int(input())

left = ''
right = S
for q in range(Q):
    Query = list(map(str, input().split()))
    if Query[0] == '1':
        #反転
        tmp = left
        left = right
        right = tmp
    else:   #Query[0]==2
        if Query[1] == '1':
            #先頭追加
            left += Query[2]
        else:   #Query[1] ==2
            #末尾追加
            right += Query[2]

ans = left[::-1] + right
print(ans)


Measured memory_bytes: 4764
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n; scan(n);
    int[] a = reads().map!(i => i-1).array;
    int[] b = reads();
    int[] c = reads();

    int pre = -100, ans=0;
    foreach (x; a) {
        ans += b[x];
        if (x == pre + 1) ans += c[pre];
        pre = x;
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <string>
#include <limits.h>
#include <iomanip>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <set>
#include <bitset>
#include <unordered_map>
#include <string.h>
#define fastIo                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL)
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MOD 1000000007

using namespace std;
int main()
{
    fastIo; 

    set<pair<int,pair<int,int>>>S;

    int n;
    cin>>n;

    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    
    sort(arr,arr+n);
    int ct =0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k = j+1;k<n;k++){
                
                if(arr[i]!=arr[j] && arr[i]!=arr[k] && arr[j]!=arr[k] && arr[i]+arr[j]>arr[k]){
                    ct++;
                }
            }
        }
    }

    cout<<ct;


    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORr(i, n, 0)
#define ALL(x) (x).begin(), x.end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

int main(void){
  int n;
  cin >> n;
  cout << n*n*n << endl;
  return 0;
}

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

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

    static class TaskA {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            out.print(in.next().replace("2017", "2018"));
        }

    }
}



Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b,c,d=1; cin>>a>>b;
    if(b==1){
        cout<<0; return 0;
    }
    c=a;
    while(c<b){
        c+=(a-1);
        d++;
    }
    cout<<d<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,res=0;
	scanf("%d",&n);
	for(int t,j,i=1;i<=n;i++){
		t=i;
		j=0;
		while(t){
			t/=10;
			j++;
		}
		if(j%2)res++;
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin>> W>>H>>x>>y>>r;
    if(x >= r && y >= r && x <= W - r && y <= H - r){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
int main(void)
{
 	char a, b, c;
  	int d, e, f;
  	scanf("%c%c%c%*c", &a, &b, &c);
  	d = a - '0';
  	e = b - '0';
  	f = c - '0';
  	printf("%d", d+e+f);
}

Measured memory_bytes: 128
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long

#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
#define plus adsasa
#define minus asdadsgd 
using namespace std;
 
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}

ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;
 
const int N = 3e5 + 123;
int n , m , k;
int a[N], cnt[3][N];
string s;
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> n >> k;
	rep(i , 1 , n + 1)
		cin >> a[i];
	rep(i , 1 , n + 1)
		rep(j , 1 , n + 1)
			cnt[0][i] += (a[i] > a[j] and (i < j)) , cnt[1][i] += (a[i] > a[j]);
	ll ans = 0;	
	// 1 k - 1
	// 
	for(int i = 1 ; i <= n; i++){
		ans += k * cnt[0][i] % mod;
		if(ans >= mod)ans -= mod;
		ans += (k * (k - 1) / 2) % mod * cnt[1][i] % mod; 
		if(ans >= mod)ans -= mod;
	}
	cout << ans;
}

Measured memory_bytes: 4352
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int AS = 1 << 17;
ll dat[2 * AS];
const ll are = 1 << 30;
void modify(int p) {
	for (dat[p += AS] -= are; p > 1; p >>= 1) dat[p >> 1] = max(dat[p], dat[p ^ 1]);
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}

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


	int N;
	cin >> N;
	int A[100000];
	rep(i, N) {
		cin >> A[i];
		A[i]--;
		dat[AS + A[i]]++;
	}
	rep(i, N) dat[AS + i] = (dat[AS + i] << 30) + i;
	for (int i = AS - 1; i > 0; i--) dat[i] = max(dat[i << 1], dat[i << 1 | 1]);

	if (N == 2) {
		co(-1);
		return 0;
	}

	int dame = -1;
	int j = 0;
	const int m = (1 << 30) - 1;
	bool used[100000] = {};
	rep(i, N - 3) {
		int kotae;
		ll tmp = dat[1];
		if (N - i - 1 == tmp >> 30) kotae = tmp & m;
		else {
			int k = j;
			while (used[k] || k == dame) k++;
			kotae = k;
		}
		putint(kotae + 1);
		used[kotae] = 1;
		dame = A[kotae];
		while (used[j]) j++;
		//嘘っぽい
		modify(dame);
	}

	int kouho[3];
	int k = 0;
	for (int i = j; i < N; i++) {
		if (!used[i]) kouho[k++] = i;
	}
	while (1) {
		if (dame != kouho[0] && A[kouho[0]] != kouho[1] && A[kouho[1]] != kouho[2]) break;
		next_permutation(kouho, kouho + 3);
	}
	putint(kouho[0] + 1);
	putint(kouho[1] + 1);
	putint(kouho[2] + 1);

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <string.h>

#define N 300000

typedef struct{
  char name[11];
   int time;
}Data;

void enqueue(Data);
Data dequeue(void);

int head;
int tail;
Data Q[N];

int main(){

   int i;
   int n;
   int q;
   int sum_time=0;
  Data data[N];
  Data tmp;

  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s %d",data[i].name,&data[i].time);
    enqueue(data[i]);
  }

  i=0;
  
  while(i!=n){
    tmp = dequeue();
    if(tmp.time - q <= 0){
    sum_time += tmp.time;
    tmp.time = sum_time;
    data[i]=tmp;
    i++;
    }
    else{
    sum_time += q;
    tmp.time = tmp.time - q;
    enqueue(tmp);
    }
  }

  for(i=0;i<n;i++){
  printf("%s %d\n",data[i].name,data[i].time);
  }
  
  return 0;
}


 void enqueue(Data x){

   Q[tail]=x;
   tail++;
}
 
 Data dequeue(void){

   Data x;

   x=Q[head];
   head++;

   return x;
 }

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

#define INF (1<<29)

int main()
{
    int N, M;
    while (cin >> N, N) {
        cin >> M;
        int d[N][N];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                d[i][j] = INF;
            }
            d[i][i] = 0;
        }
        
        int a, b;
        for (int i = 0; i < M; i++) {
            cin >> a >> b; a--; b--;
            d[a][b] = d[b][a] = 1;
        }

        for (int k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                }
            }
        }

        int res = 0;
        for (int i = 1; i < N; i++) {
            if (d[0][i] <= 2) ++res;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4064
#include<stdio.h>
#include<stdlib.h>

int desc(const void* n1,const void* n2)
{
  return *(int*)n2 - *(int*)n1;
}

int main(void)
{
  int n;
  int t = 1;
  int sum = 0;
  scanf("%d",&n);

  int a[n+1];
  for(int i=0; i<n; i++){
    scanf("%d",&a[i]);
  }

  qsort(a,n,sizeof(int),desc);

  for(int i=0; i<n; i++ ){
    sum += t*a[i];
    t = -t;
//    printf("%d %d ",a[i],a[i+1]);
  }

  printf("%d",sum);

  return 0;

}



Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

X,K,D=map(int,input().split())
X=abs(X)
if K*D<X:
    if X>0:
        print(X-K*D)
    else:
        print(K*D+X)
else:
    a=X//D
    if (a-K)%2==0:
        print(abs(a*D-X))
    else:
        print(abs((a+1)*D-X))

Measured memory_bytes: 61984
N = int(input())
A = [int(a) for a in input().split()]
Q = int(input())

M = 10**5+3
s = sum(A)
L = [0]*(M+1)
for a in A:
    L[a] += 1

for _ in range(Q):
    b,c = map(int, input().split())
    if L[b] == 0:
        print(s)
        continue
    s = s-L[b]*b+L[b]*c
    L[c] += L[b]
    L[b] = 0
    print(s)

Measured memory_bytes: 20508
N = int(input())
M = (N - N % 10) / 10
O = (M - M % 10) / 10

if N % 10 == 7:
    print("Yes")
elif M % 10 == 7:
    print("Yes")
elif O % 10 == 7:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m);
    rep(i, m) {
        cin >> a[i];
    }
    sort(all(a));
    vector<int> need(10);
    need[1] = 2; need[2] = 5; need[3] = 5; need[4] = 4;
    need[5] = 5; need[6] = 6; need[7] = 3; need[8] =7; need[9] = 6;

    vector<int> dp(n+1, -INF); //i本使うときの桁数の最大値
    dp[0] = 0;
    rep(i, n+1) {
        rep(j, m) {
            if (i < need[a[j]]) continue;
            dp[i] = max(dp[i], dp[i-need[a[j]]]+1);
        }
    }
    string ans = "";
    int remain = dp[n];
    int match = n;

    while (match > 0) {
        per(i, m) {
            if (match < need[a[i]]) continue;
            if (dp[match-need[a[i]]] == remain-1) {
                ans += char('0' + a[i]);
                match -= need[a[i]];
                remain--;
                break;
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



map<char, int> mp;
string s;

int main () {
  cin >> s;
  int n = s.size();

  Rep(i, n) {
    mp[s[i]]++;
  }

  if (mp['N'] != 0 && mp['S'] == 0) {
    cout << "No\n";
    return 0;
  } else if (mp['N'] == 0 && mp['S'] != 0) {
    cout << "No\n";
    return 0;
  } else if (mp['W'] != 0 && mp['E'] == 0) {
    cout << "No\n";
    return 0;
  } else if (mp['W'] == 0 && mp['E'] != 0) {
    cout << "No\n";
    return 0;
  }

  cout << "Yes\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
void yes(){
  cout << "Yes" << endl;
  exit(0);
}

void no(){
  cout << "No" << endl;
  exit(0);
}

int main() {
  ll n; cin >> n;
  vector<ll> a(n);
  map<ll, ll> cnt;
  REP(i, n){
    cin >> a[i];
    cnt[a[i]]++;
  }
  ll uni = 0;
  FOREACH(x,cnt){
    uni++;
  }
  if(uni == 1){
    if(cnt[0] > 0) yes();
    else no();
  }
  if(n%3!=0) no();
  if(uni>3) no();
  //uni = 2 or 3 , n%3 == 0
  if(uni == 3){
    ll sum = 0;
    FOREACH(x,cnt){
      if(x.second != n/3) no();
      sum ^= x.first;
    }
    if(sum == 0) yes();
    else no();
  }
  // uni = 2
  if(cnt[0] != n/3) no();
  FOREACH(x,cnt){
    if(x.first !=0 && x.second == 2*n/3) yes();
  }
  no();
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;
constexpr i64 MOD = 1e9 + 7;

int main() {
    int n, k;
    cin >> n >> k;
    vvi dp(n + 1, vi(k + 1));
    dp[0][0] = 1;
    vi as(n);
    for (int i = 0; i < n; i++) {
        cin >> as[i];
    }

    vi sum(k + 1, 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            // dp[i][j] = dp[i - 1][j] + ... + dp[i - 1][max(0, j - as[i - 1])]
            if (j - as[i - 1] > 0) {
                dp[i][j] = sum[j] - sum[j - as[i - 1] - 1];
                dp[i][j] %= MOD;
                dp[i][j] += MOD;
                dp[i][j] %= MOD;
            } else {
                dp[i][j] = sum[j];
            }
        }
        for (int j = 0; j <= k; j++) {
            sum[j] = dp[i][j];
        }
        for (int j = 1; j <= k; j++) {
            sum[j] += sum[j - 1];
            sum[j] %= MOD;
        }
    }
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 80368
#define _GLIBCXX_DEBUG //提出時に消す
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int main() {
  ll k;
  cin >> k;
  ll sevens = 7;
  bool flag = false;
  int cnt = -1;
  if (k == 1) cnt = 1;
  for (int i = 1; i <= k; i++) {
    sevens %= k;
    if (sevens == 0) {
      flag = true;
      cnt = i;
      break;
    }
    else {
      sevens = sevens * 10 + 7;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3676
#include<iostream>
#include<algorithm>
#include<map>
#include<math.h>
#include<set>
#include<string>
#include<vector>
using namespace std;

#define PI 3.1415

double cr(double r)
{
  double cir = 2 * PI * r;
  return cir;
}

int main()
{
  double r;
  cin >> r;
  cout << cr(r);
  return 0;
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000001;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
    COMinit();
    int N; cin >> N;
    long long ans = 0;
    long long prev = 0;
    for (int K = N / 2; K < N; K++) {
        long long cnt = COM(K-1, N-1-K) * fac[K] % MOD * fac[N-1-K] % MOD;
        ans = (ans + (cnt - prev + MOD) * K) % MOD;
        prev = cnt;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 23680
n,l = map(int, input().split())

ans = 0

if l >= 1:
  for i in range(n):
    ans += l+i
  ans -= l
  print(ans)
elif -n < l <= 0:
  for i in range(n):
    ans += l+i
  print(ans)
elif l <= -n:
  for i in range(n):
    ans += l+i
  ans -= l+n-1
  print(ans)

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

int N, M;
vector<int> height;
vector<int> max_neighbor_height;
int a, b;
int ans;

void input(){
    cin >> N >> M;
    height.resize(N);
    max_neighbor_height.resize(N);

    for (int i=0; i< N; i++){
        cin >> height.at(i);
        max_neighbor_height.at(i) = -1;
    }
}

void updateMax(int target, int neighbor){
    if (max_neighbor_height.at(target) < height.at(neighbor)){
        max_neighbor_height.at(target) = height.at(neighbor);
    }
}

void calc_max(){
    for (int i=0; i< M; i++){
        cin >> a >> b;
        updateMax(a-1, b-1);
        updateMax(b-1, a-1);
    }
}

void printAns(){
    ans = 0;
    for (int i=0; i < N; i++){
        if (max_neighbor_height.at(i) < 0){
            ans++;
        } else if (max_neighbor_height.at(i) < height.at(i)){
            ans++;
        }
    }
    cout << ans << endl; 
}

int main(){
    input();
    calc_max();
    printAns();
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    vector<int> adj[n];
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        bool flag = true;
        for(auto e : adj[i]){
            if(h[e] >= h[i]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define ALL(v) v.begin(),v.end()
typedef long long ll;
int main() {
  int n; 
  cin >> n; 
  vector<int> d(n);
  int count; 
  rep(i,n){
    cin >> d.at(i);
    count +=d.at(i)*d.at(i);
  }
  int sum; 
  for(int i=0; i<n; i++){
  	for(int j=0; j<n; j++){
      sum+=d.at(i)*d.at(j);
    }
  }
  cout << (sum-count)/2 << endl;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n),ans(n);
    for(int i = 0; i < n; i++)
    {
        cin>>b[i];
        a[i]=b[i];
    }
    bool ok = true;
    for(int teban = n - 1; teban >= 0; teban--)
    {
        bool deleted = false;
        for(int pos = teban; pos >= 0; pos--)
        {
            if(a[pos]==pos+1)
            {
                //cout<<teban<<"\t"<<pos<<endl;
                ans[teban]=pos+1;
                a.erase(a.begin() + pos);
                deleted=true;
                break;
            }
        }
        if(deleted == false)
        {
            ok = false;
            break;
        }
    }
    
    
    
    if(ok)
    {
        for(int i = 0; i < n; i++)
        {
            cout<<ans[i]<<endl;
        }
    }
    else
    {
        cout<<-1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n = input()
a = map(int, raw_input().split())
a = sorted(a)

check = [0]*8
ex = 0
for i in range(n):
    if(a[i]<3200):
        check[a[i]/400] = 1
    else:
        ex += 1
l = max(sum(check),1)
h = sum(check)+ex
print(str(l)+' '+str(h))

Measured memory_bytes: 2568
/*~~~~~~~~~~~~~~~~~~~~~~~~*
 *  Jeevan ek rahasya hai *
 *     slow_processor     *
 * Author-maskman_lucifer *
 *~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>                                        
#define ll long long 
#define mpr make_pair
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define PI 3.141592653589793
#define lc '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll s=0;
    for(ll i=0;i<m;i++)
    {
        ll x;
        cin>>x;
        s=s+x;
    }
    if(s<=n)
    {
        cout<<n-s<<lc;
    }
    else
    {
        cout<<"-1"<<lc;
    }
    return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        long[] A = new long[N];
        for(int i=0;i<N;i++) {
            A[i] = sc.nextLong();
            if (A[i] == 0) {
                System.out.println("0");
                return;
            }
        }

        long ans = 1;
        for(int i=0;i<N;i++) {
            if (ans > 1000000000000000000L/A[i]) {
                System.out.println("-1");
                return;
            }
            ans *= A[i];
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 59228
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int main(){
  int r,g,b;
  cin >> r >> g >> b;
  if((r*100+g*10+b) % 4 == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N, A, B;
  std::cin >> N >> A >> B;

  // Main
  if (B > A * N)
    std::cout << A * N << std::endl;
  else
    std::cout << B << std::endl;

  // Output

  return 0;
}


Measured memory_bytes: 256
H = int(input())
Heap = list(map(int,input().split()))
Heap = ["dummy"] + Heap

def Node_property(Heap):
    L = ["dummy"]
    for i in range(1,H+1):
        key,par,left,right = Heap[i],None,None,None
        if i//2 != 0:
            par = Heap[i//2]
        if 2*i < H+1:
            left = Heap[2*i]
        if 2*i+1 < H+1:
            right = Heap[2*i+1]
        L.append([key,par,left,right])
    return L

Ans = Node_property(Heap)
for i in range(1,H+1):
    print("node "+str(i)+": key = "+str(Ans[i][0])+", ",end="")
    for j in range(1,4):
        if Ans[i][j] != None:
            if j == 1:
                print("parent key = ",end="")
            if j == 2:
                print("left key = ",end="")
            if j == 3:
                print("right key = ",end="")
            print(str(Ans[i][j])+", ",end="")
    print()



Measured memory_bytes: 5728
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

Measured memory_bytes: 256
import copy
n = int(input())
nums = list(map(int,input().split()))
tmp = copy.deepcopy(nums)
tmp.sort()
cand1 = tmp[n//2]
cand2 = tmp[(n//2)-1]
for i in range(n):
    if nums[i] < cand1:
        print(cand1)
    else:
        print(cand2)


Measured memory_bytes: 25732
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
 
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");
 
T lread(T = long)()
{
    return readln.chomp.to!T();
}
 
T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}
 
void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

long disit_sum(long a)
{
    long sum,disit_num;
    foreach(disit;0 .. 9)
    {
        disit_num = a / pow(10, disit);
        sum += disit_num % 10;
    }
    return sum;
}


void main()
{
    long n = lread();
    auto value = aryread();
    auto cost = aryread();
    foreach(i; 0 .. n)
    {
        value[i] -= cost[i];
    }
    long max_gets;
    foreach(i; 0 .. n)
    {
        if(value[i] > 0)
        {
            max_gets += value[i];
        }
    }
    writeln(max_gets);
}

Measured memory_bytes: 256
import numpy as np

mat = np.array([list(map(int, input().split())) for _ in range(3)], 'i')

for a0 in range(101):
    v0 = mat[0, :] - a0
    if len(np.where(v0 < 0)[0]) > 0: break
    for a1 in range(101):
        v1 = mat[1, :] - a1
        if len(np.where(v1 < 0)[0]) > 0: break

        if v0[0] != v1[0] or v0[1] != v1[1] or v0[2] != v1[2]:
            continue
        
        v2 = mat[2, :] - v0
        if v2[0] == v2[1] and v2[0] == v2[2]:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 12572
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long A,B,K;
    cin>>A;
    cin>>B;
    cin>>K;
   long long m=A-K;
    long long n=m+B;
       if(m>=0){
         cout<<m<<"   "<<B;}
    else if(m<0&&n>=0){
        cout<<"0"<<"   "<<n;}
        else 
        cout<<"0    0";
        return 0;}
        
           

Measured memory_bytes: 256
import sys
import math

N = int(input())
A = []
B = []

for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

'''
print(A)
print(B)
'''

ans = 0

for i in range(N - 1, -1, -1):
    r = A[i] % B[i]
    ans += (B[i] - r) % B[i]

    if i == 0:
        break

    A[i - 1] += ans

print(ans)
print('test', file=sys.stderr)

Measured memory_bytes: 15080
#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    int A, P;
    cin >> A >> P;
    cout << (A * 3 + P) / 2;
    return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

S = readline().rstrip()
l,r = map(int,read().split())

def double_naive(S):
    L = len(S)
    for i in range(1,L+1):
        T = S[:i] * 2
        if len(T) > L and T[:L] == S:
            return T

def Z_algorithm(S):
    # 共通接頭辞の長さを返す
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

def F(S):
    N = len(S)
    opt_len = N
    Z = Z_algorithm(S)
    for x in range(N//2+1,N):
        z = Z[x]
        if x + z >= N:
            opt_len = x
            break
    return S[:opt_len] * 2

S = F(S)
S = F(S)
T = F(S)
S = S[:len(S)//2]
T = T[:len(T)//2]

S = np.array(list(S)) - ord('a')
T = np.array(list(T)) - ord('a')

# S,T,TS,TST,...

L = [len(S), len(T)]
for _ in range(100):
    L.append(L[-1] + L[-2])
ctr = [np.bincount(S,minlength=26), np.bincount(T,minlength=26)]
for _ in range(100):
    ctr.append(ctr[-1] + ctr[-2])

def get_dist(N,R):
    # S_NにおけるR番目以下
    if N == 0:
        return np.bincount(S[:R],minlength=26)
    if N == 1:
        return np.bincount(T[:R],minlength=26)
    if L[N-1] >= R:
        return get_dist(N-1,R)
    return ctr[N-1] + get_dist(N-2,R-L[N-1])

c = get_dist(99,r) - get_dist(99,l-1)

print(*c)

Measured memory_bytes: 23140
class Dice
  def initialize(t,s,e,w,n,b)
    @val = [t,s,e,w,n,b]
    @min = @val.min
    @sec = (@val - [@min]).min
  end
  def roll(d)
    for c in d.split("") do
      case c
      when "N" then
        @val = [@val[1],@val[5],@val[2],@val[3],@val[0],@val[4]]
      when "E" then
        @val = [@val[3],@val[1],@val[0],@val[5],@val[4],@val[2]]
      when "W" then
        @val = [@val[2],@val[1],@val[5],@val[0],@val[4],@val[3]]
      when "S" then
        @val = [@val[4],@val[0],@val[2],@val[3],@val[5],@val[1]]
      when "L" then
        @val = [@val[0],@val[3],@val[1],@val[4],@val[2],@val[5]]
      when "R" then
        @val = [@val[0],@val[2],@val[4],@val[1],@val[3],@val[5]]
      end
    end
  end
  def getEast
    return @val[2]
  end
  def changeTop(t)
    case @val.index(t)
    when 1 then
      roll("N")
    when 2 then
      roll("W")
    when 3 then
      roll("E")
    when 4 then
      roll("S")
    when 5 then
      roll("NN")
    end
  end
  def changeSouth(s)
    case @val.index(s)
    when 2 then
      roll("R")
    when 3 then
      roll("L")
    when 4 then
      roll("RR")
    end
  end
  def sort(t=@min,s=@sec)
    changeTop(t)
    changeSouth(s)
  end
end

t,s,e,w,n,b = gets.chomp.split(" ").map{|x| x.to_i}
d = Dice.new(t,s,e,w,n,b)

q = gets.chomp.to_i
for i in 1..q do
  t,s = gets.chomp.split(" ").map{|x| x.to_i}
  d.sort(t,s)
  printf("%d\n",d.getEast)
end


Measured memory_bytes: 6880
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int a,b,c;cin>>a>>b>>c;
    if(a>b) swap(a,b);
    string ans = (a <= c && c <= b) ? "Yes":"No";
    cout<<ans<<endl;
}


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

public class Main {

	public static void printArray(String[] cardSort) {
		for (int i = 0; i < cardSort.length; i++) {
			System.out.print(cardSort[i]);

			if (i == cardSort.length - 1) {
				break;
			}
			System.out.print(" ");
		}
		System.out.println();
	}

	public static boolean isStable(String in[], String out[], int N) {
		
		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				for(int a = 0; a < N; a++) {
					for(int b = a + 1; b < N; b++) {
						if(in[i].charAt(1) == in[j].charAt(1) && in[i].equals(out[b]) && in[j].equals(out[a])) {
							return false;
						}
					}
				}
			}
		}
		return true;
	}

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

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

		String[] card = br.readLine().split(" ");

		String[] cardNumBubbleSort = new String[progCardNumOfSheets];
		String[] cardNumSelectionSort = new String[progCardNumOfSheets];


		for(int i = 0; i < progCardNumOfSheets; i++) {
			cardNumBubbleSort[i] = card[i];
			cardNumSelectionSort[i] = card[i];
		}

		int compareNumResult = 0;
		String compareNum1 = "";
		String compareNum2 = "";

		boolean isSortFlag = true;

		while(isSortFlag) {
			isSortFlag = false;

			for(int i = progCardNumOfSheets - 1; i > 0; i-- ) {
				compareNum1 = cardNumBubbleSort[i].substring(1);
				compareNum2 = cardNumBubbleSort[i - 1].substring(1);
				compareNumResult = compareNum1.compareTo(compareNum2);
				if(compareNumResult < 0) {
					String tmp = cardNumBubbleSort[i - 1];
					cardNumBubbleSort[i - 1] = cardNumBubbleSort[i];
					cardNumBubbleSort[i] = tmp;
					isSortFlag = true;
				}
			}
		}

		printArray(cardNumBubbleSort);

		if(isStable(card, cardNumBubbleSort, progCardNumOfSheets)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}

		int minNum = 0;
		for(int i = 0; i < progCardNumOfSheets; i++) {
			minNum = i;

			for(int j = i; j < progCardNumOfSheets; j++) {
				compareNum1 = cardNumSelectionSort[j].substring(1);
				compareNum2 = cardNumSelectionSort[minNum].substring(1);
				compareNumResult = compareNum1.compareTo(compareNum2);
				if(compareNumResult < 0) {
					minNum = j;
				}
			}
			if(i != minNum) {
				String tmp = cardNumSelectionSort[i];
				cardNumSelectionSort[i] = cardNumSelectionSort[minNum];
				cardNumSelectionSort[minNum] = tmp;
			}
		}

		printArray(cardNumSelectionSort);

		if(isStable(card, cardNumSelectionSort, progCardNumOfSheets)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
	}
}

Measured memory_bytes: 25504
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    vector <string> day = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i = 0; i < day.size(); i++){
        if(s.compare(day[i])==0){
            cout << day.size()-i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3544
#!/usr/bin/env python
import numpy as np

A = np.array([list((int(_) for _ in input().split())) for x in range(3)])
N = int(input())
b = {int(input()) for _ in range(N)}

ans = "No"
for i in range(3):
    if (set(A[i, :]) <= b) or (set(A[:, i]) <= b):
        ans = "Yes"
if ({A[0][0], A[1][1], A[2][2]} <= b) or ({A[0][2], A[1][1], A[2][0]} <= b):
    ans = "Yes"

print(ans)


Measured memory_bytes: 20716
N, M = map(int, input().split())
scores = [[] for _ in range(8)]

for i in range(N):
  x, y, z = map(int, input().split())
  scores[0].append(+x+y+z)
  scores[1].append(+x+y-z)
  scores[2].append(+x-y+z)
  scores[3].append(-x+y+z)
  scores[4].append(+x-y-z)
  scores[5].append(-x+y-z)
  scores[6].append(-x-y+z)
  scores[7].append(-x-y-z)

ans = 0
for item in scores:
  item.sort(reverse=True)
  ans = max(ans, sum(item[0:M]))

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define endl "\n"
using namespace std;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
signed main(void)
{
    int h, w;
    while(cin >> h >> w, h or w)
    {
        int table[h][w];
        for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) cin >> table[i][j];
        int ans = 0;
        for(int i = 0; i < h; i++)
        {
            for(int j = 0; j < w; j++)
            {
                for(int k = i + 2; k < h; k++)
                {
                    for(int l = j + 2; l < w; l++)
                    {
                        int minv = INF;
                        for(int t = j; t <= l; t++) minv = min(minv, table[i][t]);
                        for(int t = j; t <= l; t++) minv = min(minv, table[k][t]);

                        for(int t = i; t <= k; t++) minv = min(minv, table[t][j]);
                        for(int t = i; t <= k; t++) minv = min(minv, table[t][l]);

                        int maxv = 0, sum = 0;
                        for(int a = i + 1; a < k; a++)
                        {
                            for(int b = j + 1; b < l; b++)
                            {
                                maxv = max(maxv, table[a][b]);
                                sum += (minv - table[a][b]);
                            }
                        }
                        if(maxv < minv)
                        {
                            ans = max(ans, sum); 
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

int main(){
    double a,b,x;
    cin >> a >> b;

    double xb = ((a + b) / 2);
    double xcheck = (xb -0.5);
    
    if((int)xb == xcheck){
        x = (int)xb + 1;
    }else{
        x = (int)xb;
    }
    cout << x << endl;
}

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


int main(){
    int n=0,q=0;
    long long ans=0;
    cin >> n;
    vector<int> hako(100005);
    for(int i=0;i<n;i++){
        int a=0;
        cin >> a;
        ans+=a;
        hako.at(a)++;
    }
    cin >> q;
    for(int i=0;i<q;i++){
        int b=0,c=0;
        cin >> b >> c;
        ans=ans+(c-b)*hako.at(b);
        hako.at(c)+=hako.at(b);
        hako.at(b)=0;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c)%mod;
    if (b&1) return (c*a)%mod;
    return c;
}
ll powerwithoutmod(ll a,ll b) {
    if (b==0) return 1;
    ll c = power(a,b>>1);
    c = (c*c);
    if (b&1) return (c*a);
    return c;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int Q = 301;
const int logN = 16;

void solve() {
	int n,p;
	cin>>n;
	REP(i,1,n) {
        cin>>p;
        if (p%2==0) {
            if (p%3 && p%5) {
                cout<<"DENIED";
                return;
            }
        }
	}
	cout<<"APPROVED";
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
    int n,cnt;
    cnt=0;
    scanf("%d",&n);
    for(int i=1;i<10;i++){
        if(n%i==0&&0<n/i&&n/i<10){
            cnt=1;
        }

    }

    if(cnt==1){
        printf("Yes");
    }else{
        printf("No");
    }

    


    return 0;

}

Measured memory_bytes: 128
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
using namespace std;

int main() {
  double m,n;
  cin >> m >> n;
  double answer;
  answer=m/n;
  cout << answer << endl;
  
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#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 sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;

    ll n;
    cin>>n;
    ll dp[100010]={};
    rep(i,n+1){
        dp[i]=i;
    }
    for(ll i=6;i<n+1;i*=6){
        rep(j,n+1){
            if(j+i<=n){
                chmin(dp[j+i],dp[j]+1);
            }
        }
    }
    for(ll i=9;i<n+1;i*=9){
        rep(j,n+1){
            if(j+i<=n){
                chmin(dp[j+i],dp[j]+1);
            }
        }
    }
    cout<<dp[n]<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = INT_MAX;
const int MOD = 1000000007;
const long long INF = LLONG_MAX;
const long long MINF = LLONG_MIN;

// -------------------------------------------------------

ll N;

int main() {
  cin >> N;
  ll ans = 0;
  repe(i, 1, N) {
    ll n = N / i;
    ans += i * n * (n + 1) / 2;
  }
  cout << ans;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  int N, K; cin >> N >> K;
  V v(N);
  rep(i, N) cin >> v[i];

  int ans = 0;
  rep(i, N+1) rep(j, N+1) {
    if (i + j > min(N, K)) continue;
    V out;
    int sum = 0;
    rep(ii, i) {
      sum += v[ii];
      out.push_back(v[ii]);
    }
    rep(jj, j) {
      sum += v[N-1-jj];
      out.push_back(v[N-1-jj]);
    }
    int gomi = 0;
    sort(all(out));
    rep(k, min(K-i-j, i+j)) {
      gomi += min(out[k], 0);
    }
    chmax(ans, sum - gomi);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256